@sisense/sdk-ui 0.15.0 → 0.16.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 (54) hide show
  1. package/dist/ai.js +2 -2
  2. package/dist/api/types/dashboard-dto.d.ts +3 -2
  3. package/dist/chart-data-options/coloring/consts.d.ts +3 -0
  4. package/dist/chart-data-options/coloring/utils.d.ts +6 -0
  5. package/dist/chart-data-options/get-translated-data-options.d.ts +6 -0
  6. package/dist/chart-options-processor/chart-options-service.d.ts +2 -74
  7. package/dist/chart-options-processor/translations/axis-section.d.ts +3 -1
  8. package/dist/chart-options-processor/translations/funnel-series.d.ts +1 -2
  9. package/dist/chart-options-processor/translations/legend-section.d.ts +2 -1
  10. package/dist/chart-options-processor/translations/pie-series.d.ts +1 -2
  11. package/dist/chart-options-processor/translations/translations-to-highcharts.d.ts +6 -2
  12. package/dist/dashboard-widget/translate-panel-color-format.d.ts +2 -2
  13. package/dist/dashboard-widget/translate-widget-data-options.d.ts +4 -4
  14. package/dist/dashboard-widget/translate-widget-style-options.d.ts +1 -1
  15. package/dist/dashboard-widget/types.d.ts +20 -17
  16. package/dist/dashboard-widget/use-fetch-widget-dto-model.d.ts +7 -1
  17. package/dist/dashboard-widget/utils.d.ts +1 -1
  18. package/dist/filters/components/common/dropdown.d.ts +8 -0
  19. package/dist/filters/components/common/index.d.ts +2 -1
  20. package/dist/filters/components/common/radio.d.ts +7 -0
  21. package/dist/filters/components/criteria-filter-tile/criteria-filter-display.d.ts +2 -2
  22. package/dist/filters/components/criteria-filter-tile/criteria-filter-menu.d.ts +5 -3
  23. package/dist/filters/components/criteria-filter-tile/criteria-filter-operations.d.ts +17 -3
  24. package/dist/filters/components/criteria-filter-tile/criteria-filter-tile.d.ts +20 -3
  25. package/dist/filters/components/member-filter-tile/basic-member-filter-tile.d.ts +2 -0
  26. package/dist/filters/components/member-filter-tile/members-reducer.d.ts +9 -1
  27. package/dist/filters/components/member-filter-tile/pill-section.d.ts +0 -1
  28. package/dist/highcharts-memorized.d.ts +4 -3
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.js +5375 -4600
  31. package/dist/models/dashboard/types.d.ts +1 -1
  32. package/dist/models/widget/get-widget-model.d.ts +4 -0
  33. package/dist/models/widget/index.d.ts +3 -1
  34. package/dist/models/widget/translate-widget.d.ts +1 -1
  35. package/dist/models/widget/use-get-widget-model.d.ts +102 -0
  36. package/dist/models/widget/widget-model.d.ts +122 -0
  37. package/dist/query/execute-query.d.ts +2 -0
  38. package/dist/query-execution/csv-query-state-reducer.d.ts +2 -0
  39. package/dist/query-execution/index.d.ts +4 -3
  40. package/dist/query-execution/query-state-reducer.d.ts +1 -58
  41. package/dist/query-execution/types.d.ts +190 -0
  42. package/dist/query-execution/use-execute-csv-query.d.ts +82 -0
  43. package/dist/query-execution/use-execute-query-by-widget-id.d.ts +2 -37
  44. package/dist/query-execution/use-execute-query.d.ts +8 -33
  45. package/dist/table/hooks/use-table-data.d.ts +5 -1
  46. package/dist/table/table.d.ts +3 -0
  47. package/dist/{table-widget-7b20ecf7.js → table-widget-5f3b1d03.js} +21968 -21679
  48. package/dist/translation/resources/en.d.ts +6 -0
  49. package/dist/translation/resources/index.d.ts +12 -0
  50. package/dist/utils/utility-types.d.ts +4 -0
  51. package/dist/widgets/common/drilldown-breadcrumbs/drilldown-breadcrumbs-navigation.d.ts +8 -0
  52. package/dist/widgets/common/drilldown-breadcrumbs/styled-buttons.d.ts +11 -0
  53. package/package.json +15 -6
  54. package/dist/models/widget/types.d.ts +0 -6
@@ -1,5 +1,5 @@
1
1
  import { type DataSource } from '@sisense/sdk-data';
2
- import { type WidgetModel } from '../widget/types';
2
+ import { WidgetModel } from '../widget/widget-model';
3
3
  export type DashboardModel = {
4
4
  oid: string;
5
5
  title: string;
@@ -0,0 +1,4 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ import { WidgetModel } from './widget-model';
3
+ /** @internal */
4
+ export declare function getWidgetModel(httpClient: HttpClient, dashboardOid: string, widgetOid: string): Promise<WidgetModel>;
@@ -1,2 +1,4 @@
1
- export * from './types';
2
1
  export * from './translate-widget';
2
+ export * from './widget-model';
3
+ export * from './get-widget-model';
4
+ export * from './use-get-widget-model';
@@ -1,3 +1,3 @@
1
1
  import { WidgetDto } from '../../dashboard-widget/types';
2
- import { WidgetModel } from './types';
2
+ import { WidgetModel } from './widget-model';
3
3
  export declare function translateWidget(widget: WidgetDto): WidgetModel;
@@ -0,0 +1,102 @@
1
+ import { HookEnableParam } from '../../common/hooks/types';
2
+ import { WidgetModel } from './widget-model';
3
+ /**
4
+ * Parameters for {@link useGetWidgetModel} hook.
5
+ */
6
+ export interface GetWidgetModelParams extends HookEnableParam {
7
+ /**
8
+ * Identifier of the dashboard that contains the widget
9
+ */
10
+ dashboardOid: string;
11
+ /**
12
+ * Identifier of the widget to be retrieved
13
+ */
14
+ widgetOid: string;
15
+ }
16
+ /**
17
+ * States of a widget model load.
18
+ */
19
+ export type WidgetModelState = WidgetModelLoadingState | WidgetModelErrorState | WidgetModelSuccessState;
20
+ /**
21
+ * State of a widget model that is loading.
22
+ */
23
+ export type WidgetModelLoadingState = {
24
+ /** Whether the widget model is loading */
25
+ isLoading: true;
26
+ /** Whether the widget model load has failed */
27
+ isError: false;
28
+ /** Whether the widget model load has succeeded */
29
+ isSuccess: false;
30
+ /** Error, if one occurred */
31
+ error: undefined;
32
+ /** Widget model, if the load succeeded */
33
+ widget: WidgetModel | undefined;
34
+ /** Loading status */
35
+ status: 'loading';
36
+ };
37
+ /**
38
+ * State of a widget model load that has failed.
39
+ */
40
+ export type WidgetModelErrorState = {
41
+ /** Whether the widget model is loading */
42
+ isLoading: false;
43
+ /** Whether the widget model load has failed */
44
+ isError: true;
45
+ /** Whether the widget model load has succeeded */
46
+ isSuccess: false;
47
+ /** Error, if one occurred */
48
+ error: Error;
49
+ /** Widget model, if the load succeeded */
50
+ widget: undefined;
51
+ /** Loading status */
52
+ status: 'error';
53
+ };
54
+ /**
55
+ * State of a widget model load that has succeeded.
56
+ */
57
+ export type WidgetModelSuccessState = {
58
+ /** Whether the widget model is loading */
59
+ isLoading: false;
60
+ /** Whether the widget model load has failed */
61
+ isError: false;
62
+ /** Whether the widget model load has succeeded */
63
+ isSuccess: true;
64
+ /** Error, if one occurred */
65
+ error: undefined;
66
+ /** Widget model, if the load succeeded */
67
+ widget: WidgetModel;
68
+ /** Loading status */
69
+ status: 'success';
70
+ };
71
+ /**
72
+ * React hook that retrieves an existing widget model from the Sisense instance.
73
+ *
74
+ * @example
75
+ * An example of retrieving an existing widget model from the Sisense instance:
76
+ ```tsx
77
+ const { widget, isLoading, isError } = useGetWidgetModel({
78
+ dashboardOid: '6448665edac1920034bce7a8',
79
+ widgetOid: '6448665edac1920034bce7a8',
80
+ });
81
+ if (isLoading) {
82
+ return <div>Loading...</div>;
83
+ }
84
+ if (isError) {
85
+ return <div>Error</div>;
86
+ }
87
+ if (widget) {
88
+ return (
89
+ <Chart {...widget.getChartProps()} />
90
+ );
91
+ }
92
+ return null;
93
+ ```
94
+ * @param params - Parameters of the widget to be retrieved
95
+ * @returns Widget load state that contains the status of the execution, the result widget model, or the error if one has occurred
96
+ */
97
+ export declare const useGetWidgetModel: (params: GetWidgetModelParams) => WidgetModelState;
98
+ /**
99
+ * {@link useGetWidgetModel} without tracking to be used inside other hooks or components in Compose SDK.
100
+ * @internal
101
+ */
102
+ export declare function useGetWidgetModelInternal(params: GetWidgetModelParams): WidgetModelState;
@@ -0,0 +1,122 @@
1
+ import { Filter } from '@sisense/sdk-data';
2
+ import { ChartDataOptions, TableDataOptions } from '../../chart-data-options/types';
3
+ import { WidgetDto, WidgetType } from '../../dashboard-widget/types';
4
+ import { ChartProps, ChartWidgetProps, TableProps, TableWidgetProps } from '../../props';
5
+ import { ExecuteQueryParams } from '../../query-execution';
6
+ import { ChartType, DrilldownOptions, StyleOptions, TableStyleOptions } from '../../types';
7
+ /**
8
+ * Widget data options.
9
+ */
10
+ export type WidgetDataOptions = ChartDataOptions | TableDataOptions;
11
+ /**
12
+ * Model of Sisense widget defined in the abstractions of Compose SDK.
13
+ */
14
+ export declare class WidgetModel {
15
+ /**
16
+ * Unique identifier of the widget.
17
+ */
18
+ oid: string;
19
+ /**
20
+ * Widget title.
21
+ */
22
+ title: string;
23
+ /**
24
+ * Widget description.
25
+ */
26
+ description: string;
27
+ /**
28
+ * Full name of the widget data source.
29
+ */
30
+ dataSource: string;
31
+ /**
32
+ * Widget type.
33
+ */
34
+ widgetType: WidgetType;
35
+ /**
36
+ * Widget data options.
37
+ */
38
+ dataOptions: WidgetDataOptions;
39
+ /**
40
+ * Widget style options.
41
+ */
42
+ styleOptions: StyleOptions | TableStyleOptions;
43
+ /**
44
+ * Widget filters.
45
+ */
46
+ filters: Filter[];
47
+ /**
48
+ * Widget highlights.
49
+ */
50
+ highlights: Filter[];
51
+ /**
52
+ * Widget chart type.
53
+ */
54
+ chartType?: ChartType;
55
+ /**
56
+ * Widget drilldown options.
57
+ */
58
+ drilldownOptions: DrilldownOptions;
59
+ /**
60
+ * Creates a new widget model.
61
+ *
62
+ * @param widgetDto - The widget DTO to be converted to a widget model
63
+ *
64
+ * @internal
65
+ */
66
+ constructor(widgetDto: WidgetDto);
67
+ /**
68
+ * Returns the parameters to be used for executing a query for the widget.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * const {data, isLoading, isError} = useExecuteQuery(widget.getExecuteQueryParams());
73
+ * ```
74
+ */
75
+ getExecuteQueryParams(): ExecuteQueryParams;
76
+ /**
77
+ * Returns the props to be used for rendering a chart.
78
+
79
+ * @example
80
+ * ```tsx
81
+ * <Chart {...widget.getChartProps()} />
82
+ * ```
83
+ *
84
+ * Note: this method is not supported for tabular widgets.
85
+ * Use {@link getTableProps} instead for getting props for the <Table> component.
86
+ */
87
+ getChartProps(): ChartProps;
88
+ /**
89
+ * Returns the props to be used for rendering a table.
90
+ * @example
91
+ * ```tsx
92
+ * <Table {...widget.getTableProps()} />
93
+ * ```
94
+ *
95
+ * Note: this method is not supported for chart widgets.
96
+ * Use {@link getChartProps} instead for getting props for the <Chart> component.
97
+ */
98
+ getTableProps(): TableProps;
99
+ /**
100
+ * Returns the props to be used for rendering a chart widget.
101
+ * @example
102
+ * ```tsx
103
+ * <ChartWidget {...widget.getChartWidgetProps()} />
104
+ * ```
105
+ *
106
+ * Note: this method is not supported for tabular widgets.
107
+ */
108
+ getChartWidgetProps(): ChartWidgetProps;
109
+ /**
110
+ * Returns the props to be used for rendering a table widget.
111
+ * @example
112
+ * ```tsx
113
+ * <TableWidget {...widget.getTableWidgetProps()} />
114
+ * ```
115
+ *
116
+ * Note: this method is not supported for chart widgets.
117
+ * Use {@link getChartWidgetProps} instead for getting props for the <ChartWidget> component.
118
+ *
119
+ * @internal
120
+ */
121
+ getTableWidgetProps(): TableWidgetProps;
122
+ }
@@ -17,3 +17,5 @@ export declare const QUERY_DEFAULT_LIMIT = 20000;
17
17
  export declare const QUERY_DEFAULT_OFFSET = 0;
18
18
  /** @internal */
19
19
  export declare const executeQuery: (queryDescription: QueryDescription, app: ClientApplication, executionConfig?: QueryExecutionConfig) => Promise<QueryResultData>;
20
+ /** @internal */
21
+ export declare const executeCsvQuery: (queryDescription: QueryDescription, app: ClientApplication, executionConfig?: QueryExecutionConfig) => Promise<Blob>;
@@ -0,0 +1,2 @@
1
+ import { CsvQueryAction, CsvQueryState } from './types.js';
2
+ export declare function downloadCsvQueryStateReducer(state: CsvQueryState, action: CsvQueryAction): CsvQueryState;
@@ -1,5 +1,6 @@
1
1
  export { ExecuteQuery } from './execute-query';
2
- export { useExecuteQuery, type ExecuteQueryParams } from './use-execute-query';
2
+ export { useExecuteQuery } from './use-execute-query';
3
+ export { useExecuteCsvQuery } from './use-execute-csv-query';
3
4
  export { ExecuteQueryByWidgetId } from './execute-query-by-widget-id';
4
- export { useExecuteQueryByWidgetId, type ExecuteQueryByWidgetIdParams, type QueryByWidgetIdState, executeQueryByWidgetId, } from './use-execute-query-by-widget-id';
5
- export type { QueryState, QueryLoadingState, QuerySuccessState, QueryErrorState, } from './query-state-reducer';
5
+ export { useExecuteQueryByWidgetId, executeQueryByWidgetId, } from './use-execute-query-by-widget-id';
6
+ export type { QueryState, QueryLoadingState, QuerySuccessState, QueryErrorState, CsvQueryState, CsvQueryLoadingState, CsvQuerySuccessState, CsvQueryErrorState, ExecuteQueryParams, ExecuteCsvQueryParams, ExecuteQueryByWidgetIdParams, QueryByWidgetIdState, } from './types';
@@ -1,59 +1,2 @@
1
- import { QueryResultData } from '@sisense/sdk-data';
2
- import { DataLoadAction } from '../common/hooks/data-load-state-reducer';
3
- /**
4
- * State of a query execution.
5
- */
6
- export type QueryState = QueryLoadingState | QueryErrorState | QuerySuccessState;
7
- /**
8
- * State of a query execution that is loading.
9
- */
10
- export type QueryLoadingState = {
11
- /** Whether the query is loading */
12
- isLoading: true;
13
- /** Whether the query has failed */
14
- isError: false;
15
- /** Whether the query has succeeded */
16
- isSuccess: false;
17
- /** The error if any occurred */
18
- error: undefined;
19
- /** The result data if the query has succeeded */
20
- data: QueryResultData | undefined;
21
- /** The status of the query execution */
22
- status: 'loading';
23
- };
24
- /**
25
- * State of a query execution that has failed.
26
- */
27
- export type QueryErrorState = {
28
- /** Whether the query is loading */
29
- isLoading: false;
30
- /** Whether the query has failed */
31
- isError: true;
32
- /** Whether the query has succeeded */
33
- isSuccess: false;
34
- /** The error if any occurred */
35
- error: Error;
36
- /** The result data if the query has succeeded */
37
- data: undefined;
38
- /** The status of the query execution */
39
- status: 'error';
40
- };
41
- /**
42
- * State of a query execution that has succeeded.
43
- */
44
- export type QuerySuccessState = {
45
- /** Whether the query is loading */
46
- isLoading: false;
47
- /** Whether the query has failed */
48
- isError: false;
49
- /** Whether the query has succeeded */
50
- isSuccess: true;
51
- /** The error if any occurred */
52
- error: undefined;
53
- /** The result data if the query has succeeded */
54
- data: QueryResultData;
55
- /** The status of the query execution */
56
- status: 'success';
57
- };
58
- export type QueryAction = DataLoadAction<QueryResultData>;
1
+ import { QueryAction, QueryState } from './types';
59
2
  export declare function queryStateReducer(state: QueryState, action: QueryAction): QueryState;
@@ -0,0 +1,190 @@
1
+ import { Attribute, DataSource, Filter, Measure, QueryResultData } from '@sisense/sdk-data';
2
+ import { DataLoadAction } from '../common/hooks/data-load-state-reducer';
3
+ import { FiltersMergeStrategy } from '../dashboard-widget/types';
4
+ /**
5
+ * State of a query execution.
6
+ */
7
+ export type CsvQueryState = CsvQueryLoadingState | CsvQueryErrorState | CsvQuerySuccessState;
8
+ /**
9
+ * State of a query execution that is loading.
10
+ */
11
+ export type CsvQueryLoadingState = {
12
+ /** Whether the query is loading */
13
+ isLoading: true;
14
+ /** Whether the query has failed */
15
+ isError: false;
16
+ /** Whether the query has succeeded */
17
+ isSuccess: false;
18
+ /** The error if any occurred */
19
+ error: undefined;
20
+ /** The result data if the query has succeeded */
21
+ data: Blob | string | undefined;
22
+ /** The status of the query execution */
23
+ status: 'loading';
24
+ };
25
+ /**
26
+ * State of a query execution that has failed.
27
+ */
28
+ export type CsvQueryErrorState = {
29
+ /** Whether the query is loading */
30
+ isLoading: false;
31
+ /** Whether the query has failed */
32
+ isError: true;
33
+ /** Whether the query has succeeded */
34
+ isSuccess: false;
35
+ /** The error if any occurred */
36
+ error: Error;
37
+ /** The result data if the query has succeeded */
38
+ data: undefined;
39
+ /** The status of the query execution */
40
+ status: 'error';
41
+ };
42
+ /**
43
+ * State of a query execution that has succeeded.
44
+ */
45
+ export type CsvQuerySuccessState = {
46
+ /** Whether the query is loading */
47
+ isLoading: false;
48
+ /** Whether the query has failed */
49
+ isError: false;
50
+ /** Whether the query has succeeded */
51
+ isSuccess: true;
52
+ /** The error if any occurred */
53
+ error: undefined;
54
+ /** The result data if the query has succeeded */
55
+ data: Blob | string;
56
+ /** The status of the query execution */
57
+ status: 'success';
58
+ };
59
+ export type CsvQueryAction = DataLoadAction<Blob | string>;
60
+ /**
61
+ * State of a query execution.
62
+ */
63
+ export type QueryState = QueryLoadingState | QueryErrorState | QuerySuccessState;
64
+ /**
65
+ * State of a query execution that is loading.
66
+ */
67
+ export type QueryLoadingState = {
68
+ /** Whether the query is loading */
69
+ isLoading: true;
70
+ /** Whether the query has failed */
71
+ isError: false;
72
+ /** Whether the query has succeeded */
73
+ isSuccess: false;
74
+ /** The error if any occurred */
75
+ error: undefined;
76
+ /** The result data if the query has succeeded */
77
+ data: QueryResultData | undefined;
78
+ /** The status of the query execution */
79
+ status: 'loading';
80
+ };
81
+ /**
82
+ * State of a query execution that has failed.
83
+ */
84
+ export type QueryErrorState = {
85
+ /** Whether the query is loading */
86
+ isLoading: false;
87
+ /** Whether the query has failed */
88
+ isError: true;
89
+ /** Whether the query has succeeded */
90
+ isSuccess: false;
91
+ /** The error if any occurred */
92
+ error: Error;
93
+ /** The result data if the query has succeeded */
94
+ data: undefined;
95
+ /** The status of the query execution */
96
+ status: 'error';
97
+ };
98
+ /**
99
+ * State of a query execution that has succeeded.
100
+ */
101
+ export type QuerySuccessState = {
102
+ /** Whether the query is loading */
103
+ isLoading: false;
104
+ /** Whether the query has failed */
105
+ isError: false;
106
+ /** Whether the query has succeeded */
107
+ isSuccess: true;
108
+ /** The error if any occurred */
109
+ error: undefined;
110
+ /** The result data if the query has succeeded */
111
+ data: QueryResultData;
112
+ /** The status of the query execution */
113
+ status: 'success';
114
+ };
115
+ export type QueryAction = DataLoadAction<QueryResultData>;
116
+ /**
117
+ * Parameters for {@link useExecuteQueryByWidgetId} hook.
118
+ */
119
+ export interface ExecuteQueryByWidgetIdParams {
120
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.widgetOid} */
121
+ widgetOid: string;
122
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.dashboardOid} */
123
+ dashboardOid: string;
124
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.filters} */
125
+ filters?: Filter[];
126
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.highlights} */
127
+ highlights?: Filter[];
128
+ /** {@inheritDoc ExecuteQueryProps.count} */
129
+ count?: number;
130
+ /** {@inheritDoc ExecuteQueryProps.offset} */
131
+ offset?: number;
132
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.filtersMergeStrategy} */
133
+ filtersMergeStrategy?: FiltersMergeStrategy;
134
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.includeDashboardFilters} */
135
+ includeDashboardFilters?: boolean;
136
+ /** {@inheritDoc ExecuteQueryByWidgetIdProps.onBeforeQuery} */
137
+ onBeforeQuery?: (jaql: any) => any | Promise<any>;
138
+ /**
139
+ * Boolean flag to control if query is executed
140
+ *
141
+ * If not specified, the default value is `true`
142
+ */
143
+ enabled?: boolean;
144
+ }
145
+ export type QueryByWidgetIdState = QueryState & {
146
+ /** Query parameters constructed over the widget */
147
+ query: ExecuteQueryParams | undefined;
148
+ };
149
+ /**
150
+ * Parameters for {@link useExecuteQuery} hook.
151
+ */
152
+ export interface ExecuteQueryParams {
153
+ /**
154
+ * Data source the query is run against - e.g. `Sample ECommerce`
155
+ *
156
+ * If not specified, the query will use the `defaultDataSource` specified in the parent Sisense Context.
157
+ */
158
+ dataSource?: DataSource;
159
+ /** Dimensions of the query */
160
+ dimensions?: Attribute[];
161
+ /** Measures of the query */
162
+ measures?: Measure[];
163
+ /** Filters that will slice query results */
164
+ filters?: Filter[];
165
+ /** Highlight filters that will highlight results that pass filter criteria */
166
+ highlights?: Filter[];
167
+ /** {@inheritDoc ExecuteQueryProps.count} */
168
+ count?: number;
169
+ /** {@inheritDoc ExecuteQueryProps.offset} */
170
+ offset?: number;
171
+ /**
172
+ * Boolean flag to control if query is executed
173
+ *
174
+ * If not specified, the default value is `true`
175
+ */
176
+ enabled?: boolean;
177
+ /** {@inheritDoc ExecuteQueryProps.onBeforeQuery} */
178
+ onBeforeQuery?: (jaql: any) => any | Promise<any>;
179
+ }
180
+ /**
181
+ * Parameters for {@link useExecuteCsvQuery} hook.
182
+ */
183
+ export interface ExecuteCsvQueryParams extends ExecuteQueryParams {
184
+ config?: {
185
+ /**
186
+ * If set to true, the data will be returned as a Blob.
187
+ */
188
+ asDataStream?: boolean;
189
+ };
190
+ }
@@ -0,0 +1,82 @@
1
+ import { CsvQueryState, ExecuteCsvQueryParams } from './types.js';
2
+ /**
3
+ * React hook that executes a CSV data query.
4
+ * Similar to {@link useExecuteQuery}, but returns the data in CSV format as text or as a stream.
5
+ *
6
+ * @example
7
+ * An example of using the hook to obtain data in a CSV string:
8
+ ```tsx
9
+ const { data, isLoading, isError } = useExecuteCsvQuery({
10
+ dataSource: DM.DataSource,
11
+ dimensions: [DM.Commerce.AgeRange],
12
+ measures: [measures.sum(DM.Commerce.Revenue)],
13
+ filters: [filters.greaterThan(DM.Commerce.Revenue, 1000)],
14
+ });
15
+ if (isLoading) {
16
+ return <div>Loading...</div>;
17
+ }
18
+ if (isError) {
19
+ return <div>Error</div>;
20
+ }
21
+ if (data) {
22
+ return <div>{`CSV as string: ${data}`}</div>;
23
+ }
24
+ return null;
25
+ ```
26
+ * An example of using the hook to obtain data in CSV format as a stream, translating headers, and triggering file download:
27
+ ```tsx
28
+ const { data, isLoading, isError } = useExecuteCsvQuery({
29
+ dataSource: DM.DataSource,
30
+ dimensions: [DM.Commerce.AgeRange],
31
+ measures: [measures.sum(DM.Commerce.Revenue)],
32
+ filters: [filters.greaterThan(DM.Commerce.Revenue, 1000)],
33
+ config: { asDataStream: true },
34
+ });
35
+ if (isLoading) {
36
+ return <div>Loading...</div>;
37
+ }
38
+ if (isError) {
39
+ return <div>Error</div>;
40
+ }
41
+ if (data) {
42
+ const reader = new FileReader();
43
+ reader.onload = () => {
44
+ if (reader.result) {
45
+ const text = reader.result as string;
46
+ const lines = text.split('\n');
47
+ // Update headers
48
+ if (lines.length > 0) {
49
+ lines[0] = translateHeaders(lines[0]); // replace with own implementation
50
+ }
51
+ // Join modified lines back to a text
52
+ const modifiedCsv = lines.join('\n');
53
+ // Create a new Blob with modified content
54
+ const modifiedBlob = new Blob([modifiedCsv], { type: 'text/csv' });
55
+ // Trigger file download
56
+ const blobURL = window.URL.createObjectURL(modifiedBlob);
57
+ const a = document.createElement('a');
58
+ a.href = blobURL;
59
+ const fileName = 'data_translated_headers'
60
+ a.download = fileName;
61
+ document.body.appendChild(a);
62
+ a.click();
63
+ window.URL.revokeObjectURL(blobURL);
64
+ document.body.removeChild(a);
65
+ }
66
+ };
67
+ reader.readAsText(data as Blob);
68
+ }
69
+ return null;
70
+ ```
71
+
72
+ *
73
+ * @param params - Parameters of the query
74
+ * @returns Query state that contains the status of the query execution, the result data, or the error if any occurred
75
+ */
76
+ export declare const useExecuteCsvQuery: (params: ExecuteCsvQueryParams) => CsvQueryState;
77
+ /**
78
+ * {@link useExecuteQuery} without tracking to be used inside other hooks or components in Compose SDK.
79
+ *
80
+ * @internal
81
+ */
82
+ export declare function useExecuteCsvQueryInternal(params: ExecuteCsvQueryParams): CsvQueryState;
@@ -1,41 +1,6 @@
1
- import { type Filter } from '@sisense/sdk-data';
2
1
  import { ExecuteQueryParams } from './';
3
- import { QueryState } from './query-state-reducer';
4
- import { FiltersMergeStrategy } from '../dashboard-widget/types';
5
2
  import { ClientApplication } from '../app/client-application';
6
- /**
7
- * Parameters for {@link useExecuteQueryByWidgetId} hook.
8
- */
9
- export interface ExecuteQueryByWidgetIdParams {
10
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.widgetOid} */
11
- widgetOid: string;
12
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.dashboardOid} */
13
- dashboardOid: string;
14
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.filters} */
15
- filters?: Filter[];
16
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.highlights} */
17
- highlights?: Filter[];
18
- /** {@inheritDoc ExecuteQueryProps.count} */
19
- count?: number;
20
- /** {@inheritDoc ExecuteQueryProps.offset} */
21
- offset?: number;
22
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.filtersMergeStrategy} */
23
- filtersMergeStrategy?: FiltersMergeStrategy;
24
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.includeDashboardFilters} */
25
- includeDashboardFilters?: boolean;
26
- /** {@inheritDoc ExecuteQueryByWidgetIdProps.onBeforeQuery} */
27
- onBeforeQuery?: (jaql: any) => any | Promise<any>;
28
- /**
29
- * Boolean flag to control if query is executed
30
- *
31
- * If not specified, the default value is `true`
32
- */
33
- enabled?: boolean;
34
- }
35
- export type QueryByWidgetIdState = QueryState & {
36
- /** Query parameters constructed over the widget */
37
- query: ExecuteQueryParams | undefined;
38
- };
3
+ import { ExecuteQueryByWidgetIdParams, QueryByWidgetIdState } from './types';
39
4
  /**
40
5
  * React hook that executes a data query extracted from an existing widget in the Sisense instance.
41
6
  *
@@ -81,6 +46,6 @@ export declare function isParamsChanged(prevParams: ExecuteQueryByWidgetIdParams
81
46
  export declare function executeQueryByWidgetId({ widgetOid, dashboardOid, filters, highlights, filtersMergeStrategy, count, offset, includeDashboardFilters, app, onBeforeQuery, }: ExecuteQueryByWidgetIdParams & {
82
47
  app: ClientApplication;
83
48
  }): Promise<{
84
- data: import("@sisense/sdk-data").QueryResultData;
49
+ data: import("packages/sdk-data/dist").QueryResultData;
85
50
  query: ExecuteQueryParams;
86
51
  }>;