@sisense/sdk-ui 1.34.0 → 2.0.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 (75) hide show
  1. package/dist/ai.cjs +9 -9
  2. package/dist/ai.js +553 -578
  3. package/dist/analytics-composer.cjs +120 -119
  4. package/dist/analytics-composer.js +3235 -2506
  5. package/dist/{derive-chart-family-5CbFzbpu.js → derive-chart-family-BLaI9-3r.js} +23488 -23351
  6. package/dist/{derive-chart-family-C3FH49ux.cjs → derive-chart-family-CxqjTyNt.cjs} +196 -196
  7. package/dist/dimensions-C-VKss5V.cjs +1 -0
  8. package/dist/dimensions-Cfq9FexH.js +200 -0
  9. package/dist/index.cjs +24 -20
  10. package/dist/index.js +5909 -6105
  11. package/dist/packages/sdk-ui/src/ai/ai-context-provider.d.ts +13 -6
  12. package/dist/packages/sdk-ui/src/ai/chat-config.d.ts +4 -2
  13. package/dist/packages/sdk-ui/src/ai/chatbot.d.ts +17 -7
  14. package/dist/packages/sdk-ui/src/ai/get-nlg-insights.d.ts +0 -21
  15. package/dist/packages/sdk-ui/src/ai/index.d.ts +4 -3
  16. package/dist/packages/sdk-ui/src/ai/use-get-nlg-insights.d.ts +0 -12
  17. package/dist/packages/sdk-ui/src/ai/use-get-nlq-result.d.ts +0 -4
  18. package/dist/packages/sdk-ui/src/ai/use-get-query-recommendations.d.ts +0 -4
  19. package/dist/packages/sdk-ui/src/analytics-composer/{common → code}/stringify-props.d.ts +10 -2
  20. package/dist/packages/sdk-ui/src/analytics-composer/common/custom-superjson.d.ts +16 -0
  21. package/dist/packages/sdk-ui/src/analytics-composer/dashboard/dashboard-composer.d.ts +8 -0
  22. package/dist/packages/sdk-ui/src/analytics-composer/dashboard/stringify-widgets.d.ts +3 -0
  23. package/dist/packages/sdk-ui/src/analytics-composer/dashboard/to-dashboard-code.d.ts +3 -0
  24. package/dist/packages/sdk-ui/src/analytics-composer/index.d.ts +1 -0
  25. package/dist/packages/sdk-ui/src/analytics-composer/query/index.d.ts +1 -0
  26. package/dist/packages/sdk-ui/src/analytics-composer/query/query-translator.d.ts +1 -0
  27. package/dist/packages/sdk-ui/src/analytics-composer/query/simplify-metadata-item.d.ts +9 -0
  28. package/dist/packages/sdk-ui/src/analytics-composer/types.d.ts +78 -4
  29. package/dist/packages/sdk-ui/src/analytics-composer/widget/chart-options/get-widget-options.d.ts +1 -1
  30. package/dist/packages/sdk-ui/src/analytics-composer/widget/to-widget-code.d.ts +3 -1
  31. package/dist/packages/sdk-ui/src/app/client-application.d.ts +3 -55
  32. package/dist/packages/sdk-ui/src/area-range-chart.d.ts +0 -1
  33. package/dist/packages/sdk-ui/src/common/components/menu/types.d.ts +1 -0
  34. package/dist/packages/sdk-ui/src/dashboard/dashboard-helpers.d.ts +0 -11
  35. package/dist/packages/sdk-ui/src/dashboard/index.d.ts +1 -1
  36. package/dist/packages/sdk-ui/src/dashboard/types.d.ts +7 -3
  37. package/dist/packages/sdk-ui/src/dashboard/use-composed-dashboard.d.ts +1 -4
  38. package/dist/packages/sdk-ui/src/filters/components/criteria-filter-tile/index.d.ts +0 -1
  39. package/dist/packages/sdk-ui/src/filters/components/filter-tile.d.ts +0 -1
  40. package/dist/packages/sdk-ui/src/index-typedoc.d.ts +4 -1
  41. package/dist/packages/sdk-ui/src/index.d.ts +4 -3
  42. package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dashboard-model-reducer.d.ts +15 -1
  43. package/dist/packages/sdk-ui/src/models/widget/types.d.ts +1 -1
  44. package/dist/packages/sdk-ui/src/models/widget/widget-model-translator.d.ts +2 -12
  45. package/dist/packages/sdk-ui/src/models/widget/widget-model.d.ts +1 -125
  46. package/dist/packages/sdk-ui/src/props.d.ts +25 -45
  47. package/dist/packages/sdk-ui/src/query-execution/types.d.ts +1 -3
  48. package/dist/packages/sdk-ui/src/translation/resources/en.d.ts +2 -1
  49. package/dist/packages/sdk-ui/src/translation/resources/index.d.ts +4 -2
  50. package/dist/packages/sdk-ui/src/types.d.ts +48 -41
  51. package/dist/packages/sdk-ui/src/utils/{utility-types.d.ts → utility-types/basic-utility-types.d.ts} +0 -34
  52. package/dist/packages/sdk-ui/src/utils/utility-types/distributive-omit.d.ts +24 -0
  53. package/dist/packages/sdk-ui/src/utils/utility-types/index.d.ts +4 -0
  54. package/dist/packages/sdk-ui/src/utils/utility-types/rest-api-hook-state.d.ts +35 -0
  55. package/dist/packages/sdk-ui/src/utils/utility-types/soft-union.d.ts +35 -0
  56. package/dist/packages/sdk-ui/src/widget-by-id/translate-dashboard-filters.d.ts +0 -7
  57. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-data-options.d.ts +2 -2
  58. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-drilldown-options.d.ts +2 -2
  59. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-style-options.d.ts +2 -2
  60. package/dist/packages/sdk-ui/src/widget-by-id/types.d.ts +2 -2
  61. package/dist/packages/sdk-ui/src/widget-by-id/utils.d.ts +23 -16
  62. package/dist/packages/sdk-ui/src/widgets/widget.d.ts +0 -1
  63. package/dist/{use-common-filters-CqGo6jp3.cjs → use-common-filters-BGGGgJJ5.cjs} +13 -13
  64. package/dist/{use-common-filters-Bw15BNGn.js → use-common-filters-Cmyb86sc.js} +4618 -4637
  65. package/dist/widget-composer-BJURHrVD.cjs +428 -0
  66. package/dist/widget-composer-C4rwNt4P.js +959 -0
  67. package/package.json +12 -9
  68. package/dist/packages/sdk-ui/src/ai/common/beta-label.d.ts +0 -1
  69. package/dist/packages/sdk-ui/src/analytics-composer/widget/stringify-props.d.ts +0 -8
  70. package/dist/packages/sdk-ui/src/filters/components/criteria-filter-tile/types.d.ts +0 -8
  71. package/dist/packages/sdk-ui/src/utils/check-and-notify-about-deprecated-prop.d.ts +0 -1
  72. package/dist/packages/sdk-ui/src/widget-by-id/dashboard-widget.d.ts +0 -27
  73. package/dist/widget-composer-C5_iIuZN.js +0 -742
  74. package/dist/widget-composer-D5_iKTui.cjs +0 -316
  75. /package/dist/packages/sdk-ui/src/analytics-composer/{widget → code}/stringify-filters.d.ts +0 -0
@@ -1,742 +0,0 @@
1
- var V = Object.defineProperty, H = Object.defineProperties;
2
- var G = Object.getOwnPropertyDescriptors;
3
- var W = Object.getOwnPropertySymbols;
4
- var X = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable;
5
- var q = (e, t, r) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, u = (e, t) => {
6
- for (var r in t || (t = {}))
7
- X.call(t, r) && q(e, r, t[r]);
8
- if (W)
9
- for (var r of W(t))
10
- Z.call(t, r) && q(e, r, t[r]);
11
- return e;
12
- }, v = (e, t) => H(e, G(t));
13
- import { a as Q, y as ee, M as w, T as p, dG as te, dH as h, dI as A, aN as re, aw as ie, aT as ae, r as C, dJ as se, aD as D, ar as ne, ac as oe, bE as P } from "./derive-chart-family-5CbFzbpu.js";
14
- class k extends Q {
15
- constructor(t, r) {
16
- var i;
17
- super((i = t.jaql.title) !== null && i !== void 0 ? i : "", r), this.expression = t.jaql.dim || t.jaql.formula, this.metadataItem = t, t.jaql.agg ? this.aggregation = t.jaql.agg : delete this.aggregation, t.jaql.formula ? this.formula = t.jaql.formula : delete this.formula, t.jaql.sort ? this.sortType = ee(t.jaql.sort) : delete this.sortType, this.skipValidation = !0;
18
- }
19
- get id() {
20
- return this.expression;
21
- }
22
- jaql(t) {
23
- return t === !0 ? this.metadataItem.jaql : this.metadataItem;
24
- }
25
- }
26
- const le = {
27
- text: w.TextAttribute,
28
- numeric: w.NumericAttribute,
29
- datetime: w.DateLevel
30
- };
31
- function B(e) {
32
- var t;
33
- return new k(e, (t = le[e.jaql.datatype]) !== null && t !== void 0 ? t : "numeric");
34
- }
35
- const _e = {
36
- jaql: {
37
- datasource: {
38
- title: ""
39
- },
40
- metadata: []
41
- },
42
- queryTitle: "",
43
- chartRecommendations: {}
44
- }, Re = {
45
- model: "",
46
- metadata: [],
47
- chart: {},
48
- queryTitle: ""
49
- }, ze = (e) => "widgetProps" in e, de = (e) => "dashboardOid" in e && "widgetOid" in e;
50
- function ue(e) {
51
- return e.replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
52
- }
53
- function Ke(e) {
54
- return e.charAt(0).toUpperCase() + e.slice(1);
55
- }
56
- function Ue(e) {
57
- const t = /\[(.+?)\s\(Calendar\)\]/;
58
- return e.replace(t, "[$1]").trim();
59
- }
60
- function Ye(e) {
61
- if (e)
62
- if (e.metadata) {
63
- if (!e.model)
64
- throw new p("errors.missingModelTitle");
65
- } else
66
- throw new p("errors.missingMetadata");
67
- else
68
- throw new p("errors.emptyModel");
69
- return e;
70
- }
71
- function ce(e) {
72
- return !e || !e.jaql.datasource.title || !e.jaql.metadata.length;
73
- }
74
- function F(e) {
75
- if (![
76
- ...te,
77
- "pivot",
78
- "pivot2"
79
- ].includes(e))
80
- throw new p("errors.chartTypeNotSupported", {
81
- chartType: e
82
- });
83
- }
84
- function me(e) {
85
- return "widgetType" in e && e.widgetType === "pivot";
86
- }
87
- function y(e) {
88
- var t;
89
- return "column" in e && ((t = e.column) == null ? void 0 : t.expression) && /\(.*\)/.test(e.column.expression);
90
- }
91
- function N(e) {
92
- const t = "measures" in e && o(e.measures) || "values" in e && o(e.values);
93
- return me(e) ? "values" in e.dataOptions && o(e.dataOptions.values) : "chartType" in e ? e.chartType === "indicator" ? "value" in e.dataOptions && o(e.dataOptions.value) || "secondary" in e.dataOptions && o(e.dataOptions.secondary) : e.chartType === "table" ? !("columns" in e.dataOptions) || !o(e.dataOptions.columns) ? !1 : e.dataOptions.columns.some((i) => y(i)) : e.chartType === "boxplot" ? !1 : e.chartType === "scatter" ? "x" in e.dataOptions && e.dataOptions.x !== void 0 && y(e.dataOptions.x) || "y" in e.dataOptions && e.dataOptions.y !== void 0 && y(e.dataOptions.y) || "size" in e.dataOptions && e.dataOptions.size !== void 0 : e.chartType === "scattermap" ? "colorBy" in e.dataOptions && e.dataOptions.colorBy !== void 0 && y(e.dataOptions.colorBy) || "details" in e.dataOptions && e.dataOptions.details !== void 0 && y(e.dataOptions.details) || "size" in e.dataOptions && e.dataOptions.size !== void 0 && y(e.dataOptions.size) : e.chartType === "areamap" ? "geo" in e.dataOptions && o(e.dataOptions.geo) && "color" in e.dataOptions && o(e.dataOptions.color) : "value" in e.dataOptions && o(e.dataOptions.value) : t;
94
- }
95
- function o(e) {
96
- return Array.isArray(e) && e.length > 0;
97
- }
98
- function pe(e) {
99
- const t = e.split(`
100
- `);
101
- for (let r = 0; r < t.length - 1; r++)
102
- if (t[r].trim() === "") {
103
- const i = t[r + 1].trim();
104
- if (i.startsWith("import *") || i.startsWith("import {")) {
105
- t.splice(r, 1);
106
- break;
107
- }
108
- }
109
- return t.join(`
110
- `);
111
- }
112
- const ge = {
113
- react: {
114
- baseChartTmpl: `import { {{componentString}} } from '@sisense/sdk-ui';
115
- {{extraImportsString}}
116
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
117
-
118
- export default function CodeExample() {
119
- return (
120
- <{{componentString}}
121
- title={'{{titleString}}'}
122
- dataSource={DM.DataSource}
123
- chartType={'{{chartTypeString}}'}
124
- dataOptions={ {{dataOptionsString}} }
125
- filters={ {{filtersString}} }
126
- styleOptions={ {{styleOptionsString}} }
127
- drilldownOptions={ {{drilldownOptionsString}} }
128
- />
129
- );
130
- }`,
131
- chartTmpl: "{{baseChartTmpl}}",
132
- chartWidgetTmpl: "{{baseChartTmpl}}",
133
- widgetByIdTmpl: `import { WidgetById } from '@sisense/sdk-ui';
134
-
135
- const CodeExample = () => {
136
- return (
137
- <>
138
- <WidgetById
139
- widgetOid="{{widgetOid}}"
140
- dashboardOid="{{dashboardOid}}"
141
- includeDashboardFilters={true}
142
- />
143
- </>
144
- );
145
- };
146
-
147
- export default CodeExample;
148
- `,
149
- executeQueryByWidgetIdTmpl: `import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui';
150
-
151
- const CodeExample = () => {
152
- const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
153
- widgetOid: "{{widgetOid}}",
154
- dashboardOid: "{{dashboardOid}}"
155
- });
156
-
157
- if (isLoading) {
158
- return <div>Loading...</div>;
159
- }
160
- if (isError) {
161
- return <div>Error: {error.message}</div>;
162
- }
163
- if (data) {
164
- return <div>Total Rows: {data.rows.length}</div>;
165
- }
166
-
167
- return null;
168
- };
169
-
170
- export default CodeExample;
171
- `,
172
- executeQueryTmpl: `import { useExecuteQuery } from '@sisense/sdk-ui';
173
- {{extraImportsString}}
174
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
175
-
176
- const CodeExample = () => {
177
- const queryProps = {
178
- dataSource: DM.DataSource,
179
- dimensions: {{dimensionsString}},
180
- measures: {{measuresString}},
181
- filters: {{filtersString}},
182
- highlights: {{highlightsString}},
183
- }
184
-
185
- const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
186
-
187
- if (isLoading) {
188
- return <div>Loading...</div>;
189
- }
190
- if (isError) {
191
- return <div>Error: {error.message}</div>;
192
- }
193
- if (data) {
194
- return <div>Total Rows: {data.rows.length}</div>;
195
- }
196
-
197
- return null;
198
- };
199
-
200
- export default CodeExample;
201
- `,
202
- executePivotQueryTmpl: `import { useExecutePivotQuery, ExecutePivotQueryParams } from '@sisense/sdk-ui';
203
- {{extraImportsString}}
204
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
205
-
206
- const CodeExample = () => {
207
- const pivotQueryProps: ExecutePivotQueryParams = {
208
- dataSource: DM.DataSource,
209
- rows: {{rowsString}},
210
- values: {{valuesString}},
211
- filters: {{filtersString}},
212
- }
213
-
214
- const { data, isLoading, isError, error } = useExecutePivotQuery(pivotQueryProps);
215
-
216
- if (isLoading) {
217
- return <div>Loading...</div>;
218
- }
219
- if (isError) {
220
- return <div>Error: {error.message}</div>;
221
- }
222
- if (data) {
223
- return <div>Total Rows: {data.table.rows.length}</div>;
224
- }
225
-
226
- return null;
227
- };
228
-
229
- export default CodeExample;
230
- `,
231
- pivotTableWidgetTmpl: `import { {{componentString}} } from '@sisense/sdk-ui';
232
- {{extraImportsString}}
233
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
234
-
235
- export default function CodeExample() {
236
- return (
237
- <{{componentString}}
238
- title={'{{titleString}}'}
239
- dataSource={DM.DataSource}
240
- dataOptions={ {{dataOptionsString}} }
241
- filters={ {{filtersString}} }
242
- styleOptions={ {{styleOptionsString}} }
243
- />
244
- );
245
- }`
246
- },
247
- angular: {
248
- baseChartTmpl: `import { Component } from '@angular/core';
249
- import { type ChartDataOptions, type ChartStyleOptions } from '@sisense/sdk-ui-angular';
250
- {{extraImportsString}}
251
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
252
-
253
- @Component({
254
- selector: 'code-example',
255
- template: \`
256
- <csdk-chart-widget
257
- [title]="'{{titleString}}'"
258
- chartType='{{chartTypeString}}'
259
- [dataSource]='DM.DataSource'
260
- [dataOptions]='dataOptions'
261
- [filters]='filters'
262
- [styleOptions]='styleOptions'
263
- [drilldownOptions]='drilldownOptions'
264
- />
265
- \`
266
- })
267
- export class CodeExample {
268
- DM = DM;
269
- dataOptions: ChartDataOptions = {{dataOptionsString}};
270
- filters = {{filtersString}};
271
- styleOptions: ChartStyleOptions = {{styleOptionsString}};
272
- drilldownOptions = {{drilldownOptionsString}};
273
- }`,
274
- chartTmpl: "{{baseChartTmpl}}",
275
- chartWidgetTmpl: "{{baseChartTmpl}}",
276
- widgetByIdTmpl: `import { Component } from '@angular/core';
277
-
278
- @Component({
279
- selector: 'code-example',
280
- template: \`
281
- <csdk-widget-by-id
282
- [widgetOid]="widgetOid"
283
- [dashboardOid]="dashboardOid"
284
- [includeDashboardFilters]="includeDashboardFilters"
285
- />
286
- \`,
287
- })
288
-
289
- export class CodeExample {
290
- widgetOid = "{{widgetOid}}";
291
- dashboardOid = "{{dashboardOid}}";
292
- includeDashboardFilters = true;
293
- }`,
294
- executeQueryByWidgetIdTmpl: `import { Component } from '@angular/core';
295
- import { QueryService } from '@sisense/sdk-ui-angular';
296
- import { type QueryResultData } from '@sisense/sdk-data';
297
-
298
- @Component({
299
- selector: 'code-example',
300
- template: \`<div>
301
- <div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
302
- <div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
303
- </div>\`,
304
- })
305
-
306
- export class CodeExample {
307
- queryResult: QueryResultData = { rows: [], columns: [] };
308
-
309
- errorMessage: string | null = null;
310
-
311
- constructor(private queryService: QueryService) {}
312
-
313
- async ngOnInit(): Promise<void> {
314
- try {
315
- const { data } = await this.queryService.executeQueryByWidgetId({
316
- widgetOid: "{{widgetOid}}",
317
- dashboardOid: "{{dashboardOid}}",
318
- });
319
- this.queryResult = data as QueryResultData;
320
- } catch(error: unknown) {
321
- if (error instanceof Error) {
322
- this.errorMessage = error.message;
323
- }
324
- }
325
- }
326
- }
327
- `,
328
- executeQueryTmpl: `import { Component } from '@angular/core';
329
- {{extraImportsString}}
330
- import { type QueryResultData } from '@sisense/sdk-data';
331
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
332
- import { QueryService } from '@sisense/sdk-ui-angular';
333
-
334
- @Component({
335
- selector: 'code-example',
336
- template: \`<div>
337
- <div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
338
- <div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
339
- </div>\`,
340
- })
341
-
342
- export class CodeExample {
343
- queryResult: QueryResultData = { rows: [], columns: [] };
344
-
345
- errorMessage: string | null = null;
346
-
347
- constructor(private queryService: QueryService) {}
348
-
349
- async ngOnInit(): Promise<void> {
350
- const queryProps = {
351
- dataSource: DM.DataSource,
352
- dimensions: {{dimensionsString}},
353
- measures: {{measuresString}},
354
- filters: {{filtersString}},
355
- highlights: {{highlightsString}},
356
- }
357
-
358
- try {
359
- const { data } = await this.queryService.executeQuery(queryProps);
360
- this.queryResult = data as QueryResultData;
361
- } catch (error: unknown) {
362
- if (error instanceof Error) {
363
- this.errorMessage = error.message;
364
- }
365
- }
366
- }
367
- }
368
- `,
369
- executePivotQueryTmpl: "Not implemented yet",
370
- pivotTableWidgetTmpl: "Not implemented yet"
371
- },
372
- vue: {
373
- baseChartTmpl: `<script setup lang="ts">
374
- import { ref } from 'vue';
375
- import { {{componentString}}, type ChartStyleOptions } from '@sisense/sdk-ui-vue';
376
- {{extraImportsString}}
377
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
378
-
379
- const dataOptions = ref({{dataOptionsString}});
380
- const filters = ref({{filtersString}});
381
- const styleOptions = ref<ChartStyleOptions>({{styleOptionsString}});
382
- const drilldownOptions = ref({{drilldownOptionsString}});
383
- <\/script>
384
-
385
- <template>
386
- <{{componentString}}
387
- chartType="{{chartTypeString}}"
388
- :dataOptions="dataOptions"
389
- :filters="filters"
390
- :styleOptions="styleOptions"
391
- :drilldownOptions="drilldownOptions"
392
- :dataSource="DM.DataSource"
393
- title="{{titleString}}" />
394
- </template>`,
395
- chartTmpl: "{{baseChartTmpl}}",
396
- chartWidgetTmpl: "{{baseChartTmpl}}",
397
- widgetByIdTmpl: `<script setup lang="ts">
398
- import { WidgetById } from '@sisense/sdk-ui-vue';
399
- <\/script>
400
- <template>
401
- <WidgetById
402
- :widgetOid="'{{widgetOid}}'"
403
- :dashboardOid="'{{dashboardOid}}'"
404
- />
405
- </template>
406
- `,
407
- executeQueryByWidgetIdTmpl: `<script setup lang="ts">
408
- import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui-vue';
409
-
410
- const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
411
- widgetOid: "{{widgetOid}}",
412
- dashboardOid: "{{dashboardOid}}"
413
- });
414
- <\/script>
415
- <template>
416
- <div>
417
- <div v-if="isLoading">Loading...</div>
418
- <div v-else-if="isError">Error: {{error.message}}</div>
419
- <div v-else-if="data">Total Rows: {{data.rows.length}}</div>
420
- </div>
421
- </template>
422
- `,
423
- executeQueryTmpl: `<script setup lang="ts">
424
- import { useExecuteQuery } from '@sisense/sdk-ui-vue';
425
- {{extraImportsString}}
426
- import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
427
-
428
- const queryProps = {
429
- dataSource: DM.DataSource,
430
- dimensions: {{dimensionsString}},
431
- measures: {{measuresString}},
432
- filters: {{filtersString}},
433
- highlights: {{highlightsString}},
434
- }
435
- const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
436
- <\/script>
437
- <template>
438
- <div>
439
- <div v-if="isLoading">Loading...</div>
440
- <div v-else-if="isError">Error: {{error.message}}</div>
441
- <div v-else-if="data">Total Rows: {{data.rows.length}}</div>
442
- </div>
443
- </template>`,
444
- executePivotQueryTmpl: "Not implemented yet",
445
- pivotTableWidgetTmpl: "Not implemented yet"
446
- }
447
- }, _ = (e, t) => ge[t][e].replace(/{{(.*?)Tmpl}}/g, (i, a) => _(`${a}Tmpl`, t)), ye = (e, t) => e.replace(/{{(.*?)}}/g, (r, i) => i in t ? t[i] : (console.warn(`Placeholder ${i} not found in data`), r)), I = (e, t, r = "react") => {
448
- const i = _(e, r);
449
- return pe(ye(i, t));
450
- }, x = `
451
- `, M = "UNKNOWN", fe = (e, t) => {
452
- let r = "";
453
- return r += `measureFactory.customFormula(
454
- `, r += " ".repeat(t), r += ` '${h(e.title)}',
455
- `, r += " ".repeat(t), r += ` '${e.formula}',
456
- `, r += " ".repeat(t), r += ` {
457
- `, Object.entries(e.context).forEach(([i, a]) => {
458
- const s = A(a.table || M, a.column || M, void 0, "DM");
459
- r += " ".repeat(t), r += ` '${i.slice(1, -1)}': ${s},
460
- `;
461
- }), r += " ".repeat(t), r += ` }
462
- `, r += " ".repeat(t), r += ")", r;
463
- }, he = (e) => {
464
- const { level: t, table: r, column: i, agg: a, title: s } = e;
465
- let n;
466
- return r && i && (n = A(r, i, t, "DM")), a && r && i && s && (n = `measureFactory.${re.aggregationFromJAQL(a)}(${n}, '${h(s)}')`), n || M;
467
- }, Oe = (e, t) => {
468
- const r = e.jaql(!1).jaql;
469
- return "formula" in r ? fe(r, t) : he(r);
470
- }, d = (e, t = 0, r = !1) => {
471
- if (!e)
472
- return "";
473
- if (typeof e == "string")
474
- return `'${h(e)}'`;
475
- if (e instanceof k)
476
- return Oe(e, t);
477
- if (e instanceof Q)
478
- return e.composeCode || "";
479
- let i = "";
480
- return Array.isArray(e) ? i += `[${e.map((a) => d(a, t + 2))}${e.length ? x + " ".repeat(t + 2) : ""}]` : (i += `{${x}`, Object.entries(e).forEach(([a, s]) => {
481
- r && (a = `'${h(a)}'`), i += " ".repeat(t + 2), Array.isArray(s) ? i += `${a}: [${s.map((n) => d(n, t + 4, r))}${s.length ? x + " ".repeat(t + 2) : ""}]` : typeof s == "object" && s !== null ? i += `${a}: ${d(s, t + 2, r)}` : [
482
- "number",
483
- "boolean",
484
- "undefined"
485
- ].includes(typeof s) || s === null ? i += `${a}: ${s}` : i += `${a}: '${h(s)}'`, i += `,${x}`;
486
- }), i += " ".repeat(t), i += "}"), i;
487
- }, E = 6;
488
- function Se(e) {
489
- return d(e, E);
490
- }
491
- function R(e) {
492
- if (!e)
493
- throw new p("errors.undefinedDataSource");
494
- let t;
495
- return typeof e == "object" && "title" in e ? t = e.title : t = e, ue(t);
496
- }
497
- function z(e, t = !0) {
498
- const r = [];
499
- return t && r.push("measureFactory"), o(e) && r.push("filterFactory"), r.length > 0 ? `import { ${r.join(", ")} } from '@sisense/sdk-data';` : "";
500
- }
501
- const L = `
502
- `, Te = (e, t) => {
503
- if (e.composeCode)
504
- return `${L}${" ".repeat(t)}${e.composeCode}`;
505
- const r = e.jaql().jaql;
506
- return `${L}${" ".repeat(t)}filterFactory.customFilter(${d(r, t, !0)})`;
507
- }, ve = (e, t = 0) => {
508
- if (!e)
509
- return "";
510
- let r = "";
511
- return r += `[${e.map((i) => Te(i, t + 2))}${e.length ? `
512
- ` + " ".repeat(t + 2) : ""}]`, r;
513
- }, K = (e) => {
514
- if (!e)
515
- return "";
516
- if (Array.isArray(e))
517
- return ve(e, 6);
518
- throw new p("errors.filterRelationsNotSupported");
519
- }, xe = [
520
- "executeQueryByWidgetIdTmpl",
521
- "widgetByIdTmpl"
522
- ], Ee = "chartWidgetTmpl", be = "pivotTableWidgetTmpl", we = (e) => e, Ce = (e, t, r) => {
523
- const i = N(e), a = {
524
- titleString: e.title,
525
- dataSourceString: R(e.dataSource),
526
- chartTypeString: we(e.chartType),
527
- dataOptionsString: Se(e.dataOptions),
528
- filtersString: K(e.filters),
529
- componentString: "ChartWidget",
530
- extraImportsString: z(e.filters || [], i),
531
- styleOptionsString: d(e.styleOptions || {}, E),
532
- drilldownOptionsString: d(e.drilldownOptions || {}, E)
533
- };
534
- return I(r, a, t);
535
- }, De = (e, t, r) => {
536
- const i = N(e), a = {
537
- titleString: e.title,
538
- dataSourceString: R(e.dataSource),
539
- dataOptionsString: d(e.dataOptions),
540
- filtersString: K(e.filters),
541
- componentString: "PivotTableWidget",
542
- extraImportsString: z(e.filters || [], i),
543
- styleOptionsString: d(e.styleOptions || {}, E)
544
- };
545
- return I(r, a, t);
546
- }, Me = ({ dashboardOid: e, widgetOid: t, uiFramework: r = "react", chartType: i = "table", includeChart: a = !0 }) => {
547
- F(i);
548
- const s = {
549
- dashboardOid: e,
550
- widgetOid: t
551
- }, n = xe[Number(a)];
552
- return I(n, s, r);
553
- }, Ie = ({ widgetProps: e, uiFramework: t = "react" }) => {
554
- if (ie(e))
555
- return F(e.chartType), Ce(e, t, Ee);
556
- if (ae(e))
557
- return De(e, t, be);
558
- throw new p("errors.otherWidgetTypesNotSupported");
559
- }, We = (e) => ({
560
- dataOptions: {
561
- columns: e.map(B)
562
- }
563
- }), qe = Object.freeze({
564
- convolution: {
565
- enabled: !0,
566
- selectedConvolutionType: "bySlicesCount",
567
- independentSlicesCount: 7
568
- },
569
- lineWidth: {
570
- width: "bold"
571
- },
572
- markers: {
573
- enabled: !1
574
- },
575
- legend: {
576
- enabled: !1
577
- },
578
- yAxis: {
579
- gridLines: !1
580
- },
581
- xAxis: {
582
- gridLines: !1
583
- }
584
- }), $ = Object.freeze({
585
- line: "line/spline",
586
- pie: "pie/donut",
587
- bar: "bar/stacked",
588
- column: "column/stackedcolumn"
589
- }), Pe = (e, t, r) => {
590
- const i = e.reduce((s, n) => (s[n.jaql.title] = n, s), {}), a = Object.entries(r).reduce((s, n) => {
591
- const [c, f] = n;
592
- return s[`${c}`] = Array.isArray(f) ? f.map((b) => {
593
- var O, S;
594
- const l = D(b);
595
- delete l.enabled;
596
- const m = i[l.column.name];
597
- if (!m)
598
- return {
599
- column: {
600
- type: "",
601
- name: l.column.name
602
- }
603
- };
604
- const g = B(m);
605
- if (m.panel === "measures")
606
- return v(u({}, l), {
607
- column: g
608
- });
609
- if (ne(g.type)) {
610
- const T = (S = (O = m.format) == null ? void 0 : O.mask) == null ? void 0 : S[m.jaql.level];
611
- if (T)
612
- return v(u({}, l), {
613
- column: g,
614
- dateFormat: T
615
- });
616
- }
617
- return v(u({}, l), {
618
- column: g
619
- });
620
- }) : f, s;
621
- }, {});
622
- switch (t) {
623
- case "cartesian":
624
- return u({
625
- category: [],
626
- value: [],
627
- breakBy: []
628
- }, a);
629
- case "categorical":
630
- return u({
631
- category: [],
632
- value: []
633
- }, a);
634
- case "scatter":
635
- return Object.keys(a).forEach((s) => {
636
- a[`${s}`] = a[`${s}`][0];
637
- }), a;
638
- case "scattermap":
639
- return Object.keys(a).forEach((s) => {
640
- s !== "geo" && (a[`${s}`] = a[`${s}`][0]);
641
- }), a;
642
- case "table":
643
- return Object.keys(a).length === 0 ? We(e).dataOptions : a;
644
- case "boxplot":
645
- case "areamap":
646
- case "indicator":
647
- default:
648
- return a;
649
- }
650
- }, j = (e, t) => {
651
- var r, i, a, s;
652
- return t === "x" ? (i = (r = e.axesMapping.category) != null ? r : e.axesMapping.x) == null ? void 0 : i.map((n) => D(n).column.name).join(", ") : (s = (a = e.axesMapping.value) != null ? a : e.axesMapping.y) == null ? void 0 : s.map((n) => D(n).column.name).join(", ");
653
- }, Le = (e, t, r = !0) => {
654
- const { chartFamily: i, axesMapping: a = {}, styleOptions: s = {} } = t, n = Pe(e, i, a);
655
- let c;
656
- return r && t.chartType in $ ? c = C(C(qe, {
657
- subtype: $[t.chartType]
658
- }), {
659
- legend: {
660
- enabled: !0,
661
- position: "right"
662
- },
663
- yAxis: {
664
- title: {
665
- enabled: !0,
666
- text: j(t, "y")
667
- }
668
- },
669
- xAxis: {
670
- title: {
671
- enabled: !0,
672
- text: j(t, "x")
673
- }
674
- }
675
- }, s) : c = C(se(), s), {
676
- dataOptions: n,
677
- chartStyleOptions: c
678
- };
679
- }, $e = (e) => "chartType" in e ? e : {
680
- chartType: "table",
681
- chartFamily: "table",
682
- axesMapping: {}
683
- }, je = (e) => e.map((t) => oe(t.jaql)), Qe = (e) => e.reduce((t, r) => {
684
- if ((r.panel === "scope" || r.jaql.filter) && t.metadataFilters.push(P(r)), r.panel !== "scope") {
685
- const i = P(r);
686
- delete i.jaql.filter, t.metadataColumns.push(i);
687
- }
688
- return t;
689
- }, {
690
- metadataColumns: [],
691
- metadataFilters: []
692
- }), Ae = (e, t) => {
693
- if (!ce(e))
694
- try {
695
- const { useCustomizedStyleOptions: r = !1 } = t || {}, { jaql: i, chartRecommendations: a, queryTitle: s } = e, { metadata: n, datasource: { title: c, id: f, type: b = "elasticube" } } = i, l = $e(a), m = l.chartType.toLowerCase(), g = {
696
- cornerRadius: "Small",
697
- header: {
698
- // remove info button and render empty toolbar instead
699
- renderToolbar: () => null
700
- }
701
- }, { metadataColumns: O, metadataFilters: S } = Qe(n), T = je(S), { dataOptions: U, chartStyleOptions: Y } = Le(O, l, r), J = u(u({}, Y), g);
702
- return {
703
- widgetType: "chart",
704
- id: s,
705
- title: s,
706
- chartType: m,
707
- dataSource: {
708
- title: c,
709
- id: f,
710
- type: b
711
- },
712
- dataOptions: U,
713
- filters: T,
714
- styleOptions: J
715
- };
716
- } catch (r) {
717
- console.error(r);
718
- return;
719
- }
720
- }, ke = (e, t) => Ae(e, t), Be = (e) => de(e) ? Me(e) : Ie(e), Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
721
- __proto__: null,
722
- toWidgetCode: Be,
723
- toWidgetProps: ke
724
- }, Symbol.toStringTag, { value: "Module" }));
725
- export {
726
- Re as E,
727
- N as a,
728
- R as b,
729
- Ke as c,
730
- d,
731
- K as e,
732
- z as f,
733
- I as g,
734
- _e as h,
735
- ze as i,
736
- de as j,
737
- ye as p,
738
- Ue as s,
739
- ke as t,
740
- Ye as v,
741
- Je as w
742
- };