@sisense/sdk-ui 1.34.0 → 2.1.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 (85) hide show
  1. package/dist/ai.cjs +9 -9
  2. package/dist/ai.js +556 -581
  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-BNMFblR9.js} +33391 -32356
  6. package/dist/derive-chart-family-DjbiaKLQ.cjs +758 -0
  7. package/dist/dimensions-DcsEnPSY.cjs +1 -0
  8. package/dist/dimensions-DeTiL-EZ.js +200 -0
  9. package/dist/index.cjs +20 -16
  10. package/dist/index.js +7114 -6994
  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 +11 -62
  32. package/dist/packages/sdk-ui/src/area-range-chart.d.ts +0 -1
  33. package/dist/packages/sdk-ui/src/chart-options-processor/translations/legend-section.d.ts +1 -0
  34. package/dist/packages/sdk-ui/src/common/components/menu/types.d.ts +1 -0
  35. package/dist/packages/sdk-ui/src/dashboard/dashboard-helpers.d.ts +0 -11
  36. package/dist/packages/sdk-ui/src/dashboard/index.d.ts +1 -1
  37. package/dist/packages/sdk-ui/src/dashboard/types.d.ts +7 -3
  38. package/dist/packages/sdk-ui/src/dashboard/use-composed-dashboard.d.ts +1 -4
  39. package/dist/packages/sdk-ui/src/emotion-cache-provider/emotion-cache-provider.d.ts +10 -0
  40. package/dist/packages/sdk-ui/src/emotion-cache-provider/index.d.ts +2 -0
  41. package/dist/packages/sdk-ui/src/emotion-cache-provider/utils.d.ts +4 -0
  42. package/dist/packages/sdk-ui/src/filters/components/criteria-filter-tile/index.d.ts +0 -1
  43. package/dist/packages/sdk-ui/src/filters/components/filter-tile.d.ts +0 -1
  44. package/dist/packages/sdk-ui/src/index-typedoc.d.ts +4 -1
  45. package/dist/packages/sdk-ui/src/index.d.ts +4 -3
  46. package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dashboard-model-reducer.d.ts +15 -1
  47. package/dist/packages/sdk-ui/src/models/widget/types.d.ts +1 -1
  48. package/dist/packages/sdk-ui/src/models/widget/widget-model-translator.d.ts +2 -12
  49. package/dist/packages/sdk-ui/src/models/widget/widget-model.d.ts +1 -125
  50. package/dist/packages/sdk-ui/src/props.d.ts +31 -45
  51. package/dist/packages/sdk-ui/src/query-execution/types.d.ts +1 -3
  52. package/dist/packages/sdk-ui/src/query-execution/use-query-cache.d.ts +4 -2
  53. package/dist/packages/sdk-ui/src/theme-provider/default-theme-settings.d.ts +1 -0
  54. package/dist/packages/sdk-ui/src/translation/resources/en.d.ts +2 -1
  55. package/dist/packages/sdk-ui/src/translation/resources/index.d.ts +4 -2
  56. package/dist/packages/sdk-ui/src/types.d.ts +50 -41
  57. package/dist/packages/sdk-ui/src/utils/get-scrollbar-width.d.ts +1 -0
  58. package/dist/packages/sdk-ui/src/utils/{utility-types.d.ts → utility-types/basic-utility-types.d.ts} +0 -34
  59. package/dist/packages/sdk-ui/src/utils/utility-types/distributive-omit.d.ts +24 -0
  60. package/dist/packages/sdk-ui/src/utils/utility-types/index.d.ts +4 -0
  61. package/dist/packages/sdk-ui/src/utils/utility-types/rest-api-hook-state.d.ts +35 -0
  62. package/dist/packages/sdk-ui/src/utils/utility-types/soft-union.d.ts +35 -0
  63. package/dist/packages/sdk-ui/src/widget-by-id/translate-dashboard-filters.d.ts +0 -7
  64. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-data-options.d.ts +2 -2
  65. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-drilldown-options.d.ts +2 -2
  66. package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-style-options.d.ts +2 -2
  67. package/dist/packages/sdk-ui/src/widget-by-id/types.d.ts +2 -2
  68. package/dist/packages/sdk-ui/src/widget-by-id/utils.d.ts +23 -16
  69. package/dist/packages/sdk-ui/src/widgets/constants.d.ts +1 -0
  70. package/dist/packages/sdk-ui/src/widgets/widget.d.ts +0 -1
  71. package/dist/{use-common-filters-Bw15BNGn.js → use-common-filters-CJNwlbbh.js} +5944 -5617
  72. package/dist/use-common-filters-DcFu4qRs.cjs +271 -0
  73. package/dist/widget-composer-BEVCXjFv.js +959 -0
  74. package/dist/widget-composer-fYnr8SDo.cjs +428 -0
  75. package/package.json +13 -9
  76. package/dist/derive-chart-family-C3FH49ux.cjs +0 -758
  77. package/dist/packages/sdk-ui/src/ai/common/beta-label.d.ts +0 -1
  78. package/dist/packages/sdk-ui/src/analytics-composer/widget/stringify-props.d.ts +0 -8
  79. package/dist/packages/sdk-ui/src/filters/components/criteria-filter-tile/types.d.ts +0 -8
  80. package/dist/packages/sdk-ui/src/utils/check-and-notify-about-deprecated-prop.d.ts +0 -1
  81. package/dist/packages/sdk-ui/src/widget-by-id/dashboard-widget.d.ts +0 -27
  82. package/dist/use-common-filters-CqGo6jp3.cjs +0 -271
  83. package/dist/widget-composer-C5_iIuZN.js +0 -742
  84. package/dist/widget-composer-D5_iKTui.cjs +0 -316
  85. /package/dist/packages/sdk-ui/src/analytics-composer/{widget → code}/stringify-filters.d.ts +0 -0
@@ -0,0 +1,959 @@
1
+ var tt = Object.defineProperty, et = Object.defineProperties;
2
+ var rt = Object.getOwnPropertyDescriptors;
3
+ var j = Object.getOwnPropertySymbols;
4
+ var it = Object.prototype.hasOwnProperty, at = Object.prototype.propertyIsEnumerable;
5
+ var $ = (t, e, r) => e in t ? tt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, o = (t, e) => {
6
+ for (var r in e || (e = {}))
7
+ it.call(e, r) && $(t, r, e[r]);
8
+ if (j)
9
+ for (var r of j(e))
10
+ at.call(e, r) && $(t, r, e[r]);
11
+ return t;
12
+ }, u = (t, e) => et(t, rt(e));
13
+ import { eh as _, a3 as st, en as nt, eo as ot, ep as lt, M as C, T as S, eq as dt, bd as R, e3 as ct, er as O, ej as z, aY as ut, bj as pt, bi as mt, m as M, es as gt, b4 as I, aO as yt, ay as ft, c4 as P, et as ht } from "./derive-chart-family-BNMFblR9.js";
14
+ class J extends _ {
15
+ constructor(e, r) {
16
+ var i;
17
+ super((i = e.jaql.title) !== null && i !== void 0 ? i : "", r), this.expression = e.jaql.dim || e.jaql.formula, this.metadataItem = e, e.jaql.agg ? this.aggregation = e.jaql.agg : delete this.aggregation, e.jaql.formula ? this.formula = e.jaql.formula : delete this.formula, e.jaql.sort ? this.sortType = st(e.jaql.sort) : delete this.sortType, this.skipValidation = !0;
18
+ }
19
+ get id() {
20
+ return this.expression;
21
+ }
22
+ jaql(e) {
23
+ return e === !0 ? this.metadataItem.jaql : this.metadataItem;
24
+ }
25
+ /**
26
+ * Gets a serializable representation of the element
27
+ */
28
+ serialize() {
29
+ const e = super.serialize();
30
+ return e.__serializable = "JaqlElement", e.metadataItem = this.metadataItem, e.type = this.type, e;
31
+ }
32
+ }
33
+ const St = {
34
+ text: C.TextAttribute,
35
+ numeric: C.NumericAttribute,
36
+ datetime: C.DateLevel
37
+ };
38
+ function Ot(t) {
39
+ var e;
40
+ return new J(t, (e = St[t.jaql.datatype]) !== null && e !== void 0 ? e : "numeric");
41
+ }
42
+ function Y(t) {
43
+ const { jaql: e } = t;
44
+ return e.formula ? nt(e) : "agg" in e && e.dim && e.datatype ? ot({
45
+ expression: e.dim,
46
+ dataType: e.datatype,
47
+ agg: e.agg || "",
48
+ granularity: e.level,
49
+ format: void 0,
50
+ sort: e.sort,
51
+ title: e.title,
52
+ dataSource: e.datasource
53
+ }) : e.dim && e.datatype ? lt({
54
+ expression: e.dim,
55
+ dataType: e.datatype,
56
+ granularity: e.level,
57
+ sort: e.sort,
58
+ title: e.title,
59
+ panel: t.panel,
60
+ dataSource: e.datasource
61
+ }) : Ot(t);
62
+ }
63
+ const ee = {
64
+ jaql: {
65
+ datasource: {
66
+ title: "",
67
+ type: "elasticube"
68
+ },
69
+ metadata: []
70
+ },
71
+ queryTitle: "",
72
+ chartRecommendations: {}
73
+ }, re = {
74
+ model: "",
75
+ metadata: [],
76
+ chart: {},
77
+ queryTitle: ""
78
+ }, ie = (t) => "widgetProps" in t, Tt = (t) => "dashboardOid" in t && "widgetOid" in t, ae = (t) => "dashboardProps" in t, se = (t) => "dashboardOid" in t;
79
+ function bt(t) {
80
+ return t.replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
81
+ }
82
+ function ne(t) {
83
+ return t.charAt(0).toUpperCase() + t.slice(1);
84
+ }
85
+ function oe(t) {
86
+ const e = /\[(.+?)\s\(Calendar\)\]/;
87
+ return t.replace(e, "[$1]").trim();
88
+ }
89
+ function le(t) {
90
+ if (t)
91
+ if (t.metadata) {
92
+ if (!t.model)
93
+ throw new S("errors.missingModelTitle");
94
+ } else
95
+ throw new S("errors.missingMetadata");
96
+ else
97
+ throw new S("errors.emptyModel");
98
+ return t;
99
+ }
100
+ function vt(t) {
101
+ return !t || !t.jaql.datasource.title || !t.jaql.metadata.length;
102
+ }
103
+ function U(t) {
104
+ if (![
105
+ ...dt,
106
+ "pivot",
107
+ "pivot2"
108
+ ].includes(t))
109
+ throw new S("errors.chartTypeNotSupported", {
110
+ chartType: t
111
+ });
112
+ }
113
+ function xt(t) {
114
+ return "widgetType" in t && t.widgetType === "pivot";
115
+ }
116
+ function h(t) {
117
+ var e;
118
+ return "column" in t && ((e = t.column) == null ? void 0 : e.expression) && /\(.*\)/.test(t.column.expression);
119
+ }
120
+ function L(t) {
121
+ const e = "measures" in t && c(t.measures) || "values" in t && c(t.values);
122
+ return xt(t) ? "values" in t.dataOptions && c(t.dataOptions.values) : "chartType" in t ? t.chartType === "indicator" ? "value" in t.dataOptions && c(t.dataOptions.value) || "secondary" in t.dataOptions && c(t.dataOptions.secondary) : t.chartType === "table" ? !("columns" in t.dataOptions) || !c(t.dataOptions.columns) ? !1 : t.dataOptions.columns.some((i) => h(i)) : t.chartType === "boxplot" ? !1 : t.chartType === "scatter" ? "x" in t.dataOptions && t.dataOptions.x !== void 0 && h(t.dataOptions.x) || "y" in t.dataOptions && t.dataOptions.y !== void 0 && h(t.dataOptions.y) || "size" in t.dataOptions && t.dataOptions.size !== void 0 : t.chartType === "scattermap" ? "colorBy" in t.dataOptions && t.dataOptions.colorBy !== void 0 && h(t.dataOptions.colorBy) || "details" in t.dataOptions && t.dataOptions.details !== void 0 && h(t.dataOptions.details) || "size" in t.dataOptions && t.dataOptions.size !== void 0 && h(t.dataOptions.size) : t.chartType === "areamap" ? "geo" in t.dataOptions && c(t.dataOptions.geo) && "color" in t.dataOptions && c(t.dataOptions.color) : "value" in t.dataOptions && c(t.dataOptions.value) : e;
123
+ }
124
+ function c(t) {
125
+ return Array.isArray(t) && t.length > 0;
126
+ }
127
+ function Et(t) {
128
+ const e = t.split(`
129
+ `);
130
+ for (let r = 0; r < e.length - 1; r++)
131
+ if (e[r].trim() === "") {
132
+ const i = e[r + 1].trim();
133
+ if (i.startsWith("import *") || i.startsWith("import {")) {
134
+ e.splice(r, 1);
135
+ break;
136
+ }
137
+ }
138
+ return e.join(`
139
+ `);
140
+ }
141
+ const Dt = {
142
+ react: {
143
+ baseChartTmpl: `import { {{componentString}} } from '@sisense/sdk-ui';
144
+ {{extraImportsString}}
145
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
146
+
147
+ export default function CodeExample() {
148
+ return (
149
+ <{{componentString}}
150
+ title={'{{titleString}}'}
151
+ dataSource={DM.DataSource}
152
+ chartType={'{{chartTypeString}}'}
153
+ dataOptions={ {{dataOptionsString}} }
154
+ filters={ {{filtersString}} }
155
+ styleOptions={ {{styleOptionsString}} }
156
+ drilldownOptions={ {{drilldownOptionsString}} }
157
+ />
158
+ );
159
+ }`,
160
+ chartTmpl: "{{baseChartTmpl}}",
161
+ chartWidgetTmpl: "{{baseChartTmpl}}",
162
+ chartWidgetPropsTmpl: `
163
+ {
164
+ id: '{{idString}}',
165
+ widgetType: '{{widgetTypeString}}',
166
+ title: '{{titleString}}',
167
+ dataSource: DM.DataSource,
168
+ chartType: '{{chartTypeString}}',
169
+ dataOptions: {{dataOptionsString}},
170
+ filters: {{filtersString}},
171
+ styleOptions: {{styleOptionsString}},
172
+ drilldownOptions: {{drilldownOptionsString}},
173
+ }`,
174
+ widgetByIdTmpl: `import { WidgetById } from '@sisense/sdk-ui';
175
+
176
+ const CodeExample = () => {
177
+ return (
178
+ <>
179
+ <WidgetById
180
+ widgetOid="{{widgetOid}}"
181
+ dashboardOid="{{dashboardOid}}"
182
+ includeDashboardFilters={true}
183
+ />
184
+ </>
185
+ );
186
+ };
187
+
188
+ export default CodeExample;
189
+ `,
190
+ executeQueryByWidgetIdTmpl: `import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui';
191
+
192
+ const CodeExample = () => {
193
+ const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
194
+ widgetOid: "{{widgetOid}}",
195
+ dashboardOid: "{{dashboardOid}}"
196
+ });
197
+
198
+ if (isLoading) {
199
+ return <div>Loading...</div>;
200
+ }
201
+ if (isError) {
202
+ return <div>Error: {error.message}</div>;
203
+ }
204
+ if (data) {
205
+ return <div>Total Rows: {data.rows.length}</div>;
206
+ }
207
+
208
+ return null;
209
+ };
210
+
211
+ export default CodeExample;
212
+ `,
213
+ executeQueryTmpl: `import { useExecuteQuery } from '@sisense/sdk-ui';
214
+ {{extraImportsString}}
215
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
216
+
217
+ const CodeExample = () => {
218
+ const queryProps = {
219
+ dataSource: DM.DataSource,
220
+ dimensions: {{dimensionsString}},
221
+ measures: {{measuresString}},
222
+ filters: {{filtersString}},
223
+ highlights: {{highlightsString}},
224
+ }
225
+
226
+ const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
227
+
228
+ if (isLoading) {
229
+ return <div>Loading...</div>;
230
+ }
231
+ if (isError) {
232
+ return <div>Error: {error.message}</div>;
233
+ }
234
+ if (data) {
235
+ return <div>Total Rows: {data.rows.length}</div>;
236
+ }
237
+
238
+ return null;
239
+ };
240
+
241
+ export default CodeExample;
242
+ `,
243
+ executePivotQueryTmpl: `import { useExecutePivotQuery, ExecutePivotQueryParams } from '@sisense/sdk-ui';
244
+ {{extraImportsString}}
245
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
246
+
247
+ const CodeExample = () => {
248
+ const pivotQueryProps: ExecutePivotQueryParams = {
249
+ dataSource: DM.DataSource,
250
+ rows: {{rowsString}},
251
+ values: {{valuesString}},
252
+ filters: {{filtersString}},
253
+ }
254
+
255
+ const { data, isLoading, isError, error } = useExecutePivotQuery(pivotQueryProps);
256
+
257
+ if (isLoading) {
258
+ return <div>Loading...</div>;
259
+ }
260
+ if (isError) {
261
+ return <div>Error: {error.message}</div>;
262
+ }
263
+ if (data) {
264
+ return <div>Total Rows: {data.table.rows.length}</div>;
265
+ }
266
+
267
+ return null;
268
+ };
269
+
270
+ export default CodeExample;
271
+ `,
272
+ pivotTableWidgetTmpl: `import { {{componentString}} } from '@sisense/sdk-ui';
273
+ {{extraImportsString}}
274
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
275
+
276
+ export default function CodeExample() {
277
+ return (
278
+ <{{componentString}}
279
+ title={'{{titleString}}'}
280
+ dataSource={DM.DataSource}
281
+ dataOptions={ {{dataOptionsString}} }
282
+ filters={ {{filtersString}} }
283
+ styleOptions={ {{styleOptionsString}} }
284
+ />
285
+ );
286
+ }`,
287
+ pivotTableWidgetPropsTmpl: `{
288
+ id: '{{idString}}',
289
+ widgetType: '{{widgetTypeString}}',
290
+ title: '{{titleString}}',
291
+ dataSource: DM.DataSource,
292
+ dataOptions: {{dataOptionsString}},
293
+ filters: {{filtersString}},
294
+ styleOptions: {{styleOptionsString}},
295
+ }`,
296
+ dashboardByIdTmpl: `import { DashboardById } from '@sisense/sdk-ui';
297
+
298
+ const CodeExample = () => {
299
+ return (
300
+ <>
301
+ <DashboardById dashboardOid="{{dashboardOid}}" />
302
+ </>
303
+ );
304
+ };
305
+
306
+ export default CodeExample;`,
307
+ dashboardTmpl: `import { useMemo } from 'react';
308
+ import { Dashboard, DashboardProps, WidgetProps } from '@sisense/sdk-ui';
309
+ import { Filter, FilterRelations } from '@sisense/sdk-data';
310
+ {{extraImportsString}}
311
+ import * as DM from './{{defaultDataSourceString}}'; // generated with @sisense/sdk-cli
312
+
313
+ export default function CodeExample() {
314
+ const dashboardProps: DashboardProps = useMemo(() => {
315
+ const widgets: WidgetProps[] = {{widgetsString}};
316
+ const filters: Filter[] | FilterRelations = {{filtersString}};
317
+
318
+ return {
319
+ title: '{{titleString}}',
320
+ widgets,
321
+ filters,
322
+ config: {
323
+ toolbar: { isVisible: true },
324
+ filtersPanel: { isVisible: true },
325
+ },
326
+ widgetsOptions: {{widgetsOptionsString}},
327
+ layoutOptions: {{layoutOptionsString}},
328
+ tabbersOptions: {{tabbersOptionsString}},
329
+ styleOptions: {{styleOptionsString}},
330
+ };
331
+ }, []);
332
+
333
+ return (
334
+ <Dashboard {...dashboardProps} />
335
+ );
336
+ }`
337
+ },
338
+ angular: {
339
+ baseChartTmpl: `import { Component } from '@angular/core';
340
+ import { type ChartDataOptions, type ChartStyleOptions } from '@sisense/sdk-ui-angular';
341
+ {{extraImportsString}}
342
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
343
+
344
+ @Component({
345
+ selector: 'code-example',
346
+ template: \`
347
+ <csdk-chart-widget
348
+ [title]="'{{titleString}}'"
349
+ chartType='{{chartTypeString}}'
350
+ [dataSource]='DM.DataSource'
351
+ [dataOptions]='dataOptions'
352
+ [filters]='filters'
353
+ [styleOptions]='styleOptions'
354
+ [drilldownOptions]='drilldownOptions'
355
+ />
356
+ \`
357
+ })
358
+ export class CodeExample {
359
+ DM = DM;
360
+ dataOptions: ChartDataOptions = {{dataOptionsString}};
361
+ filters = {{filtersString}};
362
+ styleOptions: ChartStyleOptions = {{styleOptionsString}};
363
+ drilldownOptions = {{drilldownOptionsString}};
364
+ }`,
365
+ chartTmpl: "{{baseChartTmpl}}",
366
+ chartWidgetTmpl: "{{baseChartTmpl}}",
367
+ chartWidgetPropsTmpl: `{
368
+ id: '{{idString}}',
369
+ widgetType: '{{widgetTypeString}}',
370
+ title: '{{titleString}}',
371
+ dataSource: DM.DataSource,
372
+ chartType: '{{chartTypeString}}',
373
+ dataOptions: {{dataOptionsString}},
374
+ filters: {{filtersString}},
375
+ styleOptions: {{styleOptionsString}},
376
+ drilldownOptions: {{drilldownOptionsString}},
377
+ }`,
378
+ widgetByIdTmpl: `import { Component } from '@angular/core';
379
+
380
+ @Component({
381
+ selector: 'code-example',
382
+ template: \`
383
+ <csdk-widget-by-id
384
+ [widgetOid]="widgetOid"
385
+ [dashboardOid]="dashboardOid"
386
+ [includeDashboardFilters]="includeDashboardFilters"
387
+ />
388
+ \`,
389
+ })
390
+
391
+ export class CodeExample {
392
+ widgetOid = "{{widgetOid}}";
393
+ dashboardOid = "{{dashboardOid}}";
394
+ includeDashboardFilters = true;
395
+ }`,
396
+ executeQueryByWidgetIdTmpl: `import { Component } from '@angular/core';
397
+ import { QueryService } from '@sisense/sdk-ui-angular';
398
+ import { type QueryResultData } from '@sisense/sdk-data';
399
+
400
+ @Component({
401
+ selector: 'code-example',
402
+ template: \`<div>
403
+ <div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
404
+ <div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
405
+ </div>\`,
406
+ })
407
+
408
+ export class CodeExample {
409
+ queryResult: QueryResultData = { rows: [], columns: [] };
410
+
411
+ errorMessage: string | null = null;
412
+
413
+ constructor(private queryService: QueryService) {}
414
+
415
+ async ngOnInit(): Promise<void> {
416
+ try {
417
+ const { data } = await this.queryService.executeQueryByWidgetId({
418
+ widgetOid: "{{widgetOid}}",
419
+ dashboardOid: "{{dashboardOid}}",
420
+ });
421
+ this.queryResult = data as QueryResultData;
422
+ } catch(error: unknown) {
423
+ if (error instanceof Error) {
424
+ this.errorMessage = error.message;
425
+ }
426
+ }
427
+ }
428
+ }
429
+ `,
430
+ executeQueryTmpl: `import { Component } from '@angular/core';
431
+ {{extraImportsString}}
432
+ import { type QueryResultData } from '@sisense/sdk-data';
433
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
434
+ import { QueryService } from '@sisense/sdk-ui-angular';
435
+
436
+ @Component({
437
+ selector: 'code-example',
438
+ template: \`<div>
439
+ <div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
440
+ <div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
441
+ </div>\`,
442
+ })
443
+
444
+ export class CodeExample {
445
+ queryResult: QueryResultData = { rows: [], columns: [] };
446
+
447
+ errorMessage: string | null = null;
448
+
449
+ constructor(private queryService: QueryService) {}
450
+
451
+ async ngOnInit(): Promise<void> {
452
+ const queryProps = {
453
+ dataSource: DM.DataSource,
454
+ dimensions: {{dimensionsString}},
455
+ measures: {{measuresString}},
456
+ filters: {{filtersString}},
457
+ highlights: {{highlightsString}},
458
+ }
459
+
460
+ try {
461
+ const { data } = await this.queryService.executeQuery(queryProps);
462
+ this.queryResult = data as QueryResultData;
463
+ } catch (error: unknown) {
464
+ if (error instanceof Error) {
465
+ this.errorMessage = error.message;
466
+ }
467
+ }
468
+ }
469
+ }
470
+ `,
471
+ executePivotQueryTmpl: "Not implemented yet",
472
+ pivotTableWidgetTmpl: "Not implemented yet",
473
+ pivotTableWidgetPropsTmpl: `{
474
+ id: '{{idString}}',
475
+ widgetType: '{{widgetTypeString}}',
476
+ title: '{{titleString}}',
477
+ dataSource: DM.DataSource,
478
+ dataOptions: {{dataOptionsString}},
479
+ filters: {{filtersString}},
480
+ styleOptions: {{styleOptionsString}},
481
+ }`,
482
+ dashboardByIdTmpl: `import { Component } from '@angular/core';
483
+
484
+ @Component({
485
+ selector: 'code-example',
486
+ template: \`
487
+ <csdk-dashboard-by-id
488
+ [dashboardOid]="dashboardOid"
489
+ />
490
+ \`,
491
+ })
492
+
493
+ export class CodeExample {
494
+ dashboardOid = "{{dashboardOid}}";
495
+ }`,
496
+ dashboardTmpl: "/** COMING SOON */"
497
+ },
498
+ vue: {
499
+ baseChartTmpl: `<script setup lang="ts">
500
+ import { ref } from 'vue';
501
+ import { {{componentString}}, type ChartStyleOptions } from '@sisense/sdk-ui-vue';
502
+ {{extraImportsString}}
503
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
504
+
505
+ const dataOptions = ref({{dataOptionsString}});
506
+ const filters = ref({{filtersString}});
507
+ const styleOptions = ref<ChartStyleOptions>({{styleOptionsString}});
508
+ const drilldownOptions = ref({{drilldownOptionsString}});
509
+ <\/script>
510
+
511
+ <template>
512
+ <{{componentString}}
513
+ chartType="{{chartTypeString}}"
514
+ :dataOptions="dataOptions"
515
+ :filters="filters"
516
+ :styleOptions="styleOptions"
517
+ :drilldownOptions="drilldownOptions"
518
+ :dataSource="DM.DataSource"
519
+ title="{{titleString}}" />
520
+ </template>`,
521
+ chartTmpl: "{{baseChartTmpl}}",
522
+ chartWidgetTmpl: "{{baseChartTmpl}}",
523
+ chartWidgetPropsTmpl: `{
524
+ id: '{{idString}}',
525
+ widgetType: '{{widgetTypeString}}',
526
+ title: '{{titleString}}',
527
+ dataSource: DM.DataSource,
528
+ chartType: '{{chartTypeString}}',
529
+ dataOptions: {{dataOptionsString}},
530
+ filters: {{filtersString}},
531
+ styleOptions: {{styleOptionsString}},
532
+ drilldownOptions: {{drilldownOptionsString}},
533
+ }`,
534
+ widgetByIdTmpl: `<script setup lang="ts">
535
+ import { WidgetById } from '@sisense/sdk-ui-vue';
536
+ <\/script>
537
+ <template>
538
+ <WidgetById
539
+ :widgetOid="'{{widgetOid}}'"
540
+ :dashboardOid="'{{dashboardOid}}'"
541
+ />
542
+ </template>
543
+ `,
544
+ executeQueryByWidgetIdTmpl: `<script setup lang="ts">
545
+ import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui-vue';
546
+
547
+ const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
548
+ widgetOid: "{{widgetOid}}",
549
+ dashboardOid: "{{dashboardOid}}"
550
+ });
551
+ <\/script>
552
+ <template>
553
+ <div>
554
+ <div v-if="isLoading">Loading...</div>
555
+ <div v-else-if="isError">Error: {{error.message}}</div>
556
+ <div v-else-if="data">Total Rows: {{data.rows.length}}</div>
557
+ </div>
558
+ </template>
559
+ `,
560
+ executeQueryTmpl: `<script setup lang="ts">
561
+ import { useExecuteQuery } from '@sisense/sdk-ui-vue';
562
+ {{extraImportsString}}
563
+ import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
564
+
565
+ const queryProps = {
566
+ dataSource: DM.DataSource,
567
+ dimensions: {{dimensionsString}},
568
+ measures: {{measuresString}},
569
+ filters: {{filtersString}},
570
+ highlights: {{highlightsString}},
571
+ }
572
+ const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
573
+ <\/script>
574
+ <template>
575
+ <div>
576
+ <div v-if="isLoading">Loading...</div>
577
+ <div v-else-if="isError">Error: {{error.message}}</div>
578
+ <div v-else-if="data">Total Rows: {{data.rows.length}}</div>
579
+ </div>
580
+ </template>`,
581
+ executePivotQueryTmpl: "Not implemented yet",
582
+ pivotTableWidgetTmpl: "Not implemented yet",
583
+ pivotTableWidgetPropsTmpl: `{
584
+ id: '{{idString}}',
585
+ widgetType: '{{widgetTypeString}}',
586
+ title: '{{titleString}}',
587
+ dataSource: DM.DataSource,
588
+ dataOptions: {{dataOptionsString}},
589
+ filters: {{filtersString}},
590
+ styleOptions: {{styleOptionsString}},
591
+ }`,
592
+ dashboardByIdTmpl: `<script setup lang="ts">
593
+ import { DashboardById } from '@sisense/sdk-ui-vue';
594
+ <\/script>
595
+ <template>
596
+ <DashboardById :dashboardOid="'{{dashboardOid}}'" />
597
+ </template>`,
598
+ dashboardTmpl: "/** COMING SOON */"
599
+ }
600
+ }, K = (t, e) => Dt[e][t].replace(/{{(.*?)Tmpl}}/g, (i, a) => K(`${a}Tmpl`, e)), wt = (t, e) => t.replace(/{{(.*?)}}/g, (r, i) => i in e ? e[i] : (console.warn(`Placeholder ${i} not found in data`), r)), q = (t, e, r = "react") => {
601
+ const i = K(t, r);
602
+ return Et(wt(i, e));
603
+ }, Ct = () => Object.values(ct).map((e) => R.aggregationToJAQL(e)).join("|"), V = (t) => {
604
+ const { formula: e, context: r, filter: i } = t;
605
+ if (!r || !e)
606
+ return t;
607
+ const a = Object.keys(r);
608
+ if (a.length !== 1)
609
+ return t;
610
+ const s = a[0];
611
+ if (typeof s != "string")
612
+ return t;
613
+ const n = r[`${s}`], l = Ct(), m = new RegExp(`^\\s*(${l})\\(\\[\\w+\\]\\)$`), y = e.match(m);
614
+ if (y && e.includes(s)) {
615
+ const d = y[1];
616
+ return o({
617
+ dim: n.dim,
618
+ table: n.table,
619
+ column: n.column,
620
+ datatype: n.datatype,
621
+ agg: d,
622
+ title: t.title
623
+ }, i ? {
624
+ filter: o({}, i)
625
+ } : {});
626
+ }
627
+ return t;
628
+ }, D = (t) => {
629
+ let e = t;
630
+ if ("formula" in t && (e = V(t)), "context" in e) {
631
+ const r = o({}, e.context);
632
+ Object.keys(r).forEach((i) => {
633
+ r[`${i}`] = D(r[`${i}`]);
634
+ }), e.context = r;
635
+ }
636
+ return e;
637
+ }, Mt = (t) => {
638
+ var i;
639
+ const e = t;
640
+ if (e.panel !== "scope")
641
+ return e;
642
+ const { jaql: r } = e;
643
+ return (i = r.filter) != null && i.by && (r.filter.by = V(r.filter.by)), u(o({}, e), {
644
+ jaql: r
645
+ });
646
+ }, It = (t) => {
647
+ let e = t;
648
+ e = Mt(e);
649
+ const { jaql: r, measure: i, by: a } = e;
650
+ return o(o(u(o({}, e), {
651
+ jaql: D(r)
652
+ }), a ? {
653
+ by: D(a)
654
+ } : {}), i ? {
655
+ measure: D(i)
656
+ } : {});
657
+ }, w = 6, E = `
658
+ `, W = "UNKNOWN", qt = (t, e) => {
659
+ let r = "";
660
+ return r += `measureFactory.customFormula(
661
+ `, r += " ".repeat(e), r += ` '${O(t.title)}',
662
+ `, r += " ".repeat(e), r += ` '${t.formula}',
663
+ `, r += " ".repeat(e), r += ` {
664
+ `, Object.entries(t.context).forEach(([i, a]) => {
665
+ const s = z(a.table || W, a.column || W, void 0, "DM");
666
+ r += " ".repeat(e), r += ` '${i.slice(1, -1)}': ${s},
667
+ `;
668
+ }), r += " ".repeat(e), r += ` }
669
+ `, r += " ".repeat(e), r += ")", r;
670
+ }, Wt = (t) => {
671
+ const { level: e, table: r, column: i, agg: a, title: s } = t;
672
+ let n;
673
+ return r && i && (n = z(r, i, e, "DM")), a && r && i && s && (n = `measureFactory.${R.aggregationFromJAQL(a)}(${n}, '${O(s)}')`), n || W;
674
+ }, jt = (t, e) => {
675
+ const r = t.jaql(!1).jaql;
676
+ return "formula" in r ? qt(r, e) : Wt(r);
677
+ }, p = (t, e = 0, r = !1) => {
678
+ if (!t)
679
+ return "";
680
+ if (typeof t == "string")
681
+ return `'${O(t)}'`;
682
+ if (t instanceof J)
683
+ return jt(t, e);
684
+ if (t instanceof _)
685
+ return t.composeCode || "";
686
+ let i = "";
687
+ return Array.isArray(t) ? i += `[${t.map((a) => p(a, e + 2))}${t.length ? E + " ".repeat(e + 2) : ""}]` : (i += `{${E}`, Object.entries(t).forEach(([a, s]) => {
688
+ r && typeof a == "string" && (a = `'${O(a)}'`), i += " ".repeat(e + 2), Array.isArray(s) ? i += `${a}: [${s.map((n) => p(n, e + 4, r))}${s.length ? E + " ".repeat(e + 2) : ""}]` : typeof s == "object" && s !== null ? i += `${a}: ${p(s, e + 2, r)}` : [
689
+ "number",
690
+ "boolean",
691
+ "undefined"
692
+ ].includes(typeof s) || s === null ? i += `${a}: ${s}` : typeof s == "string" ? i += `${a}: '${O(s)}'` : i += `${a}: ${s}`, i += `,${E}`;
693
+ }), i += " ".repeat(e), i += "}"), i;
694
+ };
695
+ function $t(t) {
696
+ return p(t, w);
697
+ }
698
+ function Q(t, e = "data-source-placeholder") {
699
+ if (!t)
700
+ return e;
701
+ const r = typeof t == "object" && "title" in t ? t.title : t;
702
+ return bt(r);
703
+ }
704
+ function A(t, e = !0) {
705
+ const r = [];
706
+ return e && r.push("measureFactory"), c(t) && r.push("filterFactory"), r.length > 0 ? `import { ${r.join(", ")} } from '@sisense/sdk-data';` : "";
707
+ }
708
+ const k = `
709
+ `, Pt = (t, e) => {
710
+ if (t.composeCode)
711
+ return `${k}${" ".repeat(e)}${t.composeCode}`;
712
+ const r = t.jaql().jaql;
713
+ return `${k}${" ".repeat(e)}filterFactory.customFilter(${p(r, e, !0)})`;
714
+ }, Lt = (t, e = 0) => {
715
+ if (!t)
716
+ return "";
717
+ let r = "";
718
+ return r += `[${t.map((i) => Pt(i, e + 2))}${t.length ? `
719
+ ` + " ".repeat(e + 2) : ""}]`, r;
720
+ }, B = (t) => t ? Array.isArray(t) ? Lt(t, 6) : "/** Filter relations not supported yet */" : "[]", Qt = [
721
+ "executeQueryByWidgetIdTmpl",
722
+ "widgetByIdTmpl"
723
+ ], At = "chartWidgetTmpl", kt = "pivotTableWidgetTmpl", Bt = (t) => t, Ft = ({ dashboardOid: t, widgetOid: e, uiFramework: r = "react", chartType: i = "table", includeChart: a = !0 }) => {
724
+ U(i);
725
+ const s = {
726
+ dashboardOid: t,
727
+ widgetOid: e
728
+ }, n = Qt[Number(a)];
729
+ return q(n, s, r);
730
+ }, Nt = (t, e, r) => {
731
+ if (ut(t)) {
732
+ U(t.chartType);
733
+ const i = L(t), a = {
734
+ idString: t.id,
735
+ widgetTypeString: "chart",
736
+ titleString: t.title,
737
+ dataSourceString: Q(t.dataSource),
738
+ chartTypeString: Bt(t.chartType),
739
+ dataOptionsString: $t(t.dataOptions),
740
+ filtersString: B(t.filters),
741
+ componentString: "ChartWidget",
742
+ extraImportsString: A(t.filters || [], i),
743
+ styleOptionsString: p(t.styleOptions || {}, w),
744
+ drilldownOptionsString: p(t.drilldownOptions || {}, w)
745
+ };
746
+ return q(r.chart, a, e);
747
+ }
748
+ if (pt(t)) {
749
+ const i = L(t), a = {
750
+ idString: t.id,
751
+ widgetTypeString: "pivot",
752
+ titleString: t.title,
753
+ dataSourceString: Q(t.dataSource),
754
+ dataOptionsString: p(t.dataOptions),
755
+ filtersString: B(t.filters),
756
+ componentString: "PivotTableWidget",
757
+ extraImportsString: A(t.filters || [], i),
758
+ styleOptionsString: p(t.styleOptions || {}, w)
759
+ };
760
+ return q(r.pivot, a, e);
761
+ }
762
+ if (mt(t))
763
+ return "/** Plugin widget code not supported yet */";
764
+ throw new S("errors.otherWidgetTypesNotSupported");
765
+ }, _t = ({ widgetProps: t, uiFramework: e = "react" }) => Nt(t, e, {
766
+ chart: At,
767
+ pivot: kt
768
+ }), Rt = (t) => ({
769
+ dataOptions: {
770
+ columns: t.map(Y)
771
+ }
772
+ }), zt = Object.freeze({
773
+ convolution: {
774
+ enabled: !0,
775
+ selectedConvolutionType: "bySlicesCount",
776
+ independentSlicesCount: 7
777
+ },
778
+ lineWidth: {
779
+ width: "bold"
780
+ },
781
+ markers: {
782
+ enabled: !1
783
+ },
784
+ legend: {
785
+ enabled: !1
786
+ },
787
+ yAxis: {
788
+ gridLines: !1
789
+ },
790
+ xAxis: {
791
+ gridLines: !1
792
+ }
793
+ }), F = Object.freeze({
794
+ line: "line/spline",
795
+ pie: "pie/donut",
796
+ bar: "bar/stacked",
797
+ column: "column/stackedcolumn"
798
+ }), Jt = (t, e, r) => {
799
+ const i = t.reduce((s, n) => (s[n.jaql.title] = n, s), {}), a = Object.entries(r).reduce((s, n) => {
800
+ const [l, m] = n;
801
+ return s[`${l}`] = Array.isArray(m) ? m.map((y) => {
802
+ var T, b;
803
+ const d = I(y);
804
+ delete d.enabled;
805
+ const g = i[d.column.name];
806
+ if (!g)
807
+ return {
808
+ column: {
809
+ type: "",
810
+ name: d.column.name
811
+ }
812
+ };
813
+ const f = Y(g);
814
+ if (g.panel === "measures")
815
+ return u(o({}, d), {
816
+ column: f
817
+ });
818
+ if (yt(f.type)) {
819
+ const v = (b = (T = g.format) == null ? void 0 : T.mask) == null ? void 0 : b[g.jaql.level];
820
+ if (v)
821
+ return u(o({}, d), {
822
+ column: f,
823
+ dateFormat: v
824
+ });
825
+ }
826
+ return u(o({}, d), {
827
+ column: f
828
+ });
829
+ }) : m, s;
830
+ }, {});
831
+ switch (e) {
832
+ case "cartesian":
833
+ return o({
834
+ category: [],
835
+ value: [],
836
+ breakBy: []
837
+ }, a);
838
+ case "categorical":
839
+ return o({
840
+ category: [],
841
+ value: []
842
+ }, a);
843
+ case "scatter":
844
+ return Object.keys(a).forEach((s) => {
845
+ a[`${s}`] = a[`${s}`][0];
846
+ }), a;
847
+ case "scattermap":
848
+ return Object.keys(a).forEach((s) => {
849
+ s !== "geo" && (a[`${s}`] = a[`${s}`][0]);
850
+ }), a;
851
+ case "table":
852
+ return Object.keys(a).length === 0 ? Rt(t).dataOptions : a;
853
+ case "boxplot":
854
+ case "areamap":
855
+ case "indicator":
856
+ default:
857
+ return a;
858
+ }
859
+ }, N = (t, e) => {
860
+ var r, i, a, s;
861
+ return e === "x" ? (i = (r = t.axesMapping.category) != null ? r : t.axesMapping.x) == null ? void 0 : i.map((n) => I(n).column.name).join(", ") : (s = (a = t.axesMapping.value) != null ? a : t.axesMapping.y) == null ? void 0 : s.map((n) => I(n).column.name).join(", ");
862
+ }, Yt = (t, e, r = !0) => {
863
+ const { chartFamily: i, axesMapping: a = {}, styleOptions: s = {} } = e, n = Jt(t, i, a);
864
+ let l;
865
+ return r && e.chartType in F ? l = M(M(zt, {
866
+ subtype: F[e.chartType]
867
+ }), {
868
+ legend: {
869
+ enabled: !0,
870
+ position: "right"
871
+ },
872
+ yAxis: {
873
+ title: {
874
+ enabled: !0,
875
+ text: N(e, "y")
876
+ }
877
+ },
878
+ xAxis: {
879
+ title: {
880
+ enabled: !0,
881
+ text: N(e, "x")
882
+ }
883
+ }
884
+ }, s) : l = M(gt(), s), {
885
+ dataOptions: n,
886
+ chartStyleOptions: l
887
+ };
888
+ }, Ut = (t) => "chartType" in t ? t : {
889
+ chartType: "table",
890
+ chartFamily: "table",
891
+ axesMapping: {}
892
+ }, Kt = (t) => t.map((e) => ft(e.jaql)), Vt = (t) => t.reduce((e, r) => {
893
+ if ((r.panel === "scope" || r.jaql.filter) && e.metadataFilters.push(P(r)), r.panel !== "scope") {
894
+ const i = P(r);
895
+ delete i.jaql.filter, e.metadataColumns.push(i);
896
+ }
897
+ return e;
898
+ }, {
899
+ metadataColumns: [],
900
+ metadataFilters: []
901
+ }), Ht = (t, e) => {
902
+ if (!vt(t))
903
+ try {
904
+ const { useCustomizedStyleOptions: r = !1 } = e || {}, { jaql: i, chartRecommendations: a, queryTitle: s } = t, { metadata: n, datasource: l } = i, m = u(o({}, l), {
905
+ type: l.type || "elasticube"
906
+ }), y = ht(m), d = n.map((x) => It(x)).map((x) => u(o({}, x), {
907
+ jaql: u(o({}, x.jaql), {
908
+ datasource: y
909
+ })
910
+ })), g = Ut(a), f = g.chartType.toLowerCase(), T = {
911
+ cornerRadius: "Small",
912
+ header: {
913
+ // remove info button and render empty toolbar instead
914
+ renderToolbar: () => null
915
+ }
916
+ }, { metadataColumns: b, metadataFilters: v } = Vt(d), H = Kt(v), { dataOptions: G, chartStyleOptions: X } = Yt(b, g, r), Z = o(o({}, X), T);
917
+ return {
918
+ widgetType: "chart",
919
+ id: s,
920
+ title: s,
921
+ chartType: f,
922
+ dataSource: m,
923
+ dataOptions: G,
924
+ filters: H,
925
+ styleOptions: Z
926
+ };
927
+ } catch (r) {
928
+ console.error(r);
929
+ return;
930
+ }
931
+ }, Gt = (t, e) => Ht(t, e), Xt = (t) => Tt(t) ? Ft(t) : _t(t), de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
932
+ __proto__: null,
933
+ toWidgetCode: Xt,
934
+ toWidgetProps: Gt
935
+ }, Symbol.toStringTag, { value: "Module" }));
936
+ export {
937
+ w as C,
938
+ re as E,
939
+ J,
940
+ q as a,
941
+ L as b,
942
+ ne as c,
943
+ Q as d,
944
+ B as e,
945
+ A as f,
946
+ Nt as g,
947
+ p as h,
948
+ se as i,
949
+ ee as j,
950
+ ie as k,
951
+ Tt as l,
952
+ ae as m,
953
+ It as n,
954
+ wt as p,
955
+ oe as s,
956
+ Gt as t,
957
+ le as v,
958
+ de as w
959
+ };