@sisense/sdk-ui 1.25.0 → 1.26.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.
- package/dist/ai.cjs +53 -52
- package/dist/ai.js +934 -787
- package/dist/analytics-composer.cjs +38 -38
- package/dist/analytics-composer.js +475 -464
- package/dist/{derive-chart-family-C_c2ZQQd.cjs → derive-chart-family-DOmv279l.cjs} +19 -19
- package/dist/{derive-chart-family-BlFbAr2V.js → derive-chart-family-ZvvF5lty.js} +255 -246
- package/dist/index.cjs +42 -42
- package/dist/index.js +1817 -1767
- package/dist/packages/sdk-ui/src/ai/api/types.d.ts +6 -1
- package/dist/packages/sdk-ui/src/ai/icons/close-dialog-icon.d.ts +3 -1
- package/dist/packages/sdk-ui/src/ai/icons/sisense-logo.d.ts +2 -4
- package/dist/packages/sdk-ui/src/ai/use-chat-session.d.ts +2 -1
- package/dist/packages/sdk-ui/src/analytics-composer/common/utils.d.ts +1 -1
- package/dist/packages/sdk-ui/src/analytics-composer/execute-query/execute-query-composer.d.ts +8 -1
- package/dist/packages/sdk-ui/src/analytics-composer/execute-query/to-execute-query-code.d.ts +2 -1
- package/dist/packages/sdk-ui/src/analytics-composer/types.d.ts +8 -2
- package/dist/packages/sdk-ui/src/api/rest-api.d.ts +13 -1
- package/dist/packages/sdk-ui/src/chart/helpers/use-synced-data.d.ts +14 -1
- package/dist/packages/sdk-ui/src/models/dashboard/translate-dashboard-utils.d.ts +9 -1
- package/dist/packages/sdk-ui/src/widget-by-id/types.d.ts +14 -2
- package/dist/useQuery-9lk4MNnb.cjs +889 -0
- package/dist/{useQuery-P9b5LtGq.js → useQuery-BtpTzoxI.js} +21289 -20599
- package/dist/widget-composer-DbpSzSub.cjs +298 -0
- package/dist/{widget-composer-DXM5t9rq.js → widget-composer-ygehKLLR.js} +229 -150
- package/package.json +7 -7
- package/dist/useQuery-BYxzPyc5.cjs +0 -870
- package/dist/widget-composer-DPsDPrFM.cjs +0 -237
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var C=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var w=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))B.call(t,r)&&w(e,r,t[r]);if(C)for(var r of C(t))R.call(t,r)&&w(e,r,t[r]);return e};const o=require("./derive-chart-family-DOmv279l.cjs");class I extends o.DimensionalElement{constructor(t,r){var a;super((a=t.jaql.title)!==null&&a!==void 0?a:"",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=o.getSortType(t.jaql.sort):delete this.sortType,this.skipValidation=!0}get id(){return this.expression}jaql(){return this.metadataItem}}const Y={text:o.MetadataTypes.TextAttribute,numeric:o.MetadataTypes.NumericAttribute,datetime:o.MetadataTypes.DateLevel};function W(e){var t;return new I(e,(t=Y[e.jaql.datatype])!==null&&t!==void 0?t:"numeric")}const z={jaql:{datasource:{title:""},metadata:[]},queryTitle:"",chartRecommendations:{}},K={model:"",metadata:[],chart:{},queryTitle:""},U=e=>"widgetProps"in e,$=e=>"dashboardOid"in e&&"widgetOid"in e;function J(e){return e.replace(/\s+/g,"-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function V(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){const t=/\[(.+?)\s\(Calendar\)\]/;return e.replace(t,"[$1]").trim()}function H(e){if(e)if(e.metadata){if(!e.model)throw new o.TranslatableError("errors.missingModelTitle")}else throw new o.TranslatableError("errors.missingMetadata");else throw new o.TranslatableError("errors.emptyModel");return e}function Z(e){return!e||!e.jaql.datasource.title||!e.jaql.metadata.length}function h(e){return e&&e.replace(new RegExp("(?<!\\\\)'","g"),"\\'")}function q(e){if(![...o.ALL_CHART_TYPES,"pivot","pivot2"].includes(e))throw new o.TranslatableError("errors.chartTypeNotSupported",{chartType:e})}const G={react:{baseChartTmpl:`import { {{componentString}} } from '@sisense/sdk-ui';
|
|
2
|
+
{{extraImportsString}}
|
|
3
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
4
|
+
|
|
5
|
+
export default function CodeExample() {
|
|
6
|
+
return (
|
|
7
|
+
<{{componentString}}
|
|
8
|
+
title={'{{titleString}}'}
|
|
9
|
+
dataSource={DM.DataSource}
|
|
10
|
+
chartType={'{{chartTypeString}}'}
|
|
11
|
+
dataOptions={ {{dataOptionsString}} }
|
|
12
|
+
filters={ {{filtersString}} }
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`import { WidgetById } from '@sisense/sdk-ui';
|
|
16
|
+
|
|
17
|
+
const CodeExample = () => {
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<WidgetById
|
|
21
|
+
widgetOid="{{widgetOid}}"
|
|
22
|
+
dashboardOid="{{dashboardOid}}"
|
|
23
|
+
includeDashboardFilters={true}
|
|
24
|
+
/>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default CodeExample;
|
|
30
|
+
`,executeQueryByWidgetIdTmpl:`import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui';
|
|
31
|
+
|
|
32
|
+
const CodeExample = () => {
|
|
33
|
+
const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
|
|
34
|
+
widgetOid: "{{widgetOid}}",
|
|
35
|
+
dashboardOid: "{{dashboardOid}}"
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (isLoading) {
|
|
39
|
+
return <div>Loading...</div>;
|
|
40
|
+
}
|
|
41
|
+
if (isError) {
|
|
42
|
+
return <div>Error: {error.message}</div>;
|
|
43
|
+
}
|
|
44
|
+
if (data) {
|
|
45
|
+
return <div>Total Rows: {data.rows.length}</div>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default CodeExample;
|
|
52
|
+
`,executeQueryTmpl:`import { useExecuteQuery } from '@sisense/sdk-ui';
|
|
53
|
+
{{extraImportsString}}
|
|
54
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
55
|
+
|
|
56
|
+
const CodeExample = () => {
|
|
57
|
+
const queryProps = {
|
|
58
|
+
dataSource: DM.DataSource,
|
|
59
|
+
dimensions: {{dimensionsString}},
|
|
60
|
+
measures: {{measuresString}},
|
|
61
|
+
filters: {{filtersString}},
|
|
62
|
+
highlights: {{highlightsString}},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
|
|
66
|
+
|
|
67
|
+
if (isLoading) {
|
|
68
|
+
return <div>Loading...</div>;
|
|
69
|
+
}
|
|
70
|
+
if (isError) {
|
|
71
|
+
return <div>Error: {error.message}</div>;
|
|
72
|
+
}
|
|
73
|
+
if (data) {
|
|
74
|
+
return <div>Total Rows: {data.rows.length}</div>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default CodeExample;
|
|
81
|
+
`,executePivotQueryTmpl:`import { useExecutePivotQuery, ExecutePivotQueryParams } from '@sisense/sdk-ui';
|
|
82
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
83
|
+
|
|
84
|
+
const CodeExample = () => {
|
|
85
|
+
const pivotQueryProps: ExecutePivotQueryParams = {
|
|
86
|
+
dataSource: DM.DataSource,
|
|
87
|
+
rows: {{rowsString}},
|
|
88
|
+
values: {{valuesString}},
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { data, isLoading, isError, error } = useExecutePivotQuery(pivotQueryProps);
|
|
92
|
+
|
|
93
|
+
if (isLoading) {
|
|
94
|
+
return <div>Loading...</div>;
|
|
95
|
+
}
|
|
96
|
+
if (isError) {
|
|
97
|
+
return <div>Error: {error.message}</div>;
|
|
98
|
+
}
|
|
99
|
+
if (data) {
|
|
100
|
+
return <div>Total Rows: {data.rows.length}</div>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default CodeExample;
|
|
107
|
+
`,pivotTableWidgetTmpl:`import { {{componentString}} } from '@sisense/sdk-ui';
|
|
108
|
+
{{extraImportsString}}
|
|
109
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
110
|
+
|
|
111
|
+
export default function CodeExample() {
|
|
112
|
+
return (
|
|
113
|
+
<{{componentString}}
|
|
114
|
+
title={'{{titleString}}'}
|
|
115
|
+
dataSource={DM.DataSource}
|
|
116
|
+
dataOptions={ {{dataOptionsString}} }
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}`},angular:{baseChartTmpl:`import { Component } from '@angular/core';
|
|
120
|
+
{{extraImportsString}}
|
|
121
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
122
|
+
|
|
123
|
+
@Component({
|
|
124
|
+
selector: 'code-example',
|
|
125
|
+
template: \`
|
|
126
|
+
<csdk-chart-widget
|
|
127
|
+
chartType='{{chartTypeString}}'
|
|
128
|
+
[dataSource]='DM.DataSource'
|
|
129
|
+
[dataOptions]='dataOptions'
|
|
130
|
+
[filters]='filters'
|
|
131
|
+
/>
|
|
132
|
+
\`
|
|
133
|
+
})
|
|
134
|
+
export class CodeExample {
|
|
135
|
+
DM = DM;
|
|
136
|
+
dataOptions = {{dataOptionsString}};
|
|
137
|
+
filters = {{filtersString}};
|
|
138
|
+
}`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`import { Component } from '@angular/core';
|
|
139
|
+
|
|
140
|
+
@Component({
|
|
141
|
+
selector: 'code-example',
|
|
142
|
+
template: \`
|
|
143
|
+
<csdk-widget-by-id
|
|
144
|
+
[widgetOid]="widgetOid"
|
|
145
|
+
[dashboardOid]="dashboardOid"
|
|
146
|
+
[includeDashboardFilters]="includeDashboardFilters"
|
|
147
|
+
/>
|
|
148
|
+
\`,
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
export class CodeExample {
|
|
152
|
+
widgetOid = "{{widgetOid}}";
|
|
153
|
+
dashboardOid = "{{dashboardOid}}";
|
|
154
|
+
includeDashboardFilters = true;
|
|
155
|
+
}`,executeQueryByWidgetIdTmpl:`import { Component } from '@angular/core';
|
|
156
|
+
import { QueryService } from '@sisense/sdk-ui-angular';
|
|
157
|
+
import { type QueryResultData } from '@sisense/sdk-data';
|
|
158
|
+
|
|
159
|
+
@Component({
|
|
160
|
+
selector: 'code-example',
|
|
161
|
+
template: \`<div>
|
|
162
|
+
<div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
|
|
163
|
+
<div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
|
|
164
|
+
</div>\`,
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
export class CodeExample {
|
|
168
|
+
queryResult: QueryResultData = { rows: [], columns: [] };
|
|
169
|
+
|
|
170
|
+
errorMessage: string | null = null;
|
|
171
|
+
|
|
172
|
+
constructor(private queryService: QueryService) {}
|
|
173
|
+
|
|
174
|
+
async ngOnInit(): Promise<void> {
|
|
175
|
+
try {
|
|
176
|
+
const { data } = await this.queryService.executeQueryByWidgetId({
|
|
177
|
+
widgetOid: "{{widgetOid}}",
|
|
178
|
+
dashboardOid: "{{dashboardOid}}",
|
|
179
|
+
});
|
|
180
|
+
this.queryResult = data as QueryResultData;
|
|
181
|
+
} catch(error: unknown) {
|
|
182
|
+
if (error instanceof Error) {
|
|
183
|
+
this.errorMessage = error.message;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
`,executeQueryTmpl:`import { Component } from '@angular/core';
|
|
189
|
+
{{extraImportsString}}
|
|
190
|
+
import { type QueryResultData } from '@sisense/sdk-data';
|
|
191
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
192
|
+
import { QueryService } from '@sisense/sdk-ui-angular';
|
|
193
|
+
|
|
194
|
+
@Component({
|
|
195
|
+
selector: 'code-example',
|
|
196
|
+
template: \`<div>
|
|
197
|
+
<div *ngIf="errorMessage">Error: {{ errorMessage }}</div>
|
|
198
|
+
<div *ngIf="!errorMessage">Total Rows: {{ queryResult.rows.length }}</div>
|
|
199
|
+
</div>\`,
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
export class CodeExample {
|
|
203
|
+
queryResult: QueryResultData = { rows: [], columns: [] };
|
|
204
|
+
|
|
205
|
+
errorMessage: string | null = null;
|
|
206
|
+
|
|
207
|
+
constructor(private queryService: QueryService) {}
|
|
208
|
+
|
|
209
|
+
async ngOnInit(): Promise<void> {
|
|
210
|
+
const queryProps = {
|
|
211
|
+
dataSource: DM.DataSource,
|
|
212
|
+
dimensions: {{dimensionsString}},
|
|
213
|
+
measures: {{measuresString}},
|
|
214
|
+
filters: {{filtersString}},
|
|
215
|
+
highlights: {{highlightsString}},
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const { data } = await this.queryService.executeQuery(queryProps);
|
|
220
|
+
this.queryResult = data as QueryResultData;
|
|
221
|
+
} catch (error: unknown) {
|
|
222
|
+
if (error instanceof Error) {
|
|
223
|
+
this.errorMessage = error.message;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
`,executePivotQueryTmpl:"Not implemented yet",pivotTableWidgetTmpl:"Not implemented yet"},vue:{baseChartTmpl:`<script setup lang="ts">
|
|
229
|
+
import { ref } from 'vue';
|
|
230
|
+
import { {{componentString}} } from '@sisense/sdk-ui-vue';
|
|
231
|
+
{{extraImportsString}}
|
|
232
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
233
|
+
|
|
234
|
+
const dataOptions = ref({{dataOptionsString}});
|
|
235
|
+
const filters = ref({{filtersString}});
|
|
236
|
+
<\/script>
|
|
237
|
+
|
|
238
|
+
<template>
|
|
239
|
+
<{{componentString}}
|
|
240
|
+
chartType="{{chartTypeString}}"
|
|
241
|
+
:dataOptions="dataOptions"
|
|
242
|
+
:filters="filters"
|
|
243
|
+
:dataSource="DM.DataSource"
|
|
244
|
+
title="{{titleString}}" />
|
|
245
|
+
</template>`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`<script setup lang="ts">
|
|
246
|
+
import { WidgetById } from '@sisense/sdk-ui-vue';
|
|
247
|
+
<\/script>
|
|
248
|
+
<template>
|
|
249
|
+
<WidgetById
|
|
250
|
+
:widgetOid="{{widgetOid}}"
|
|
251
|
+
:dashboardOid="{{dashboardOid}}"
|
|
252
|
+
/>
|
|
253
|
+
</template>
|
|
254
|
+
`,executeQueryByWidgetIdTmpl:`<script setup lang="ts">
|
|
255
|
+
import { useExecuteQueryByWidgetId } from '@sisense/sdk-ui-vue';
|
|
256
|
+
|
|
257
|
+
const { data, isLoading, isError, error } = useExecuteQueryByWidgetId({
|
|
258
|
+
widgetOid: "{{widgetOid}}",
|
|
259
|
+
dashboardOid: "{{dashboardOid}}"
|
|
260
|
+
});
|
|
261
|
+
<\/script>
|
|
262
|
+
<template>
|
|
263
|
+
<div>
|
|
264
|
+
<div v-if="isLoading">Loading...</div>
|
|
265
|
+
<div v-else-if="isError">Error: {{error.message}}</div>
|
|
266
|
+
<div v-else-if="data">Total Rows: {{data.rows.length}}</div>
|
|
267
|
+
</div>
|
|
268
|
+
</template>
|
|
269
|
+
`,executeQueryTmpl:`<script setup lang="ts">
|
|
270
|
+
import { useExecuteQuery } from '@sisense/sdk-ui-vue';
|
|
271
|
+
{{extraImportsString}}
|
|
272
|
+
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
273
|
+
|
|
274
|
+
const queryProps = {
|
|
275
|
+
dataSource: DM.DataSource,
|
|
276
|
+
dimensions: {{dimensionsString}},
|
|
277
|
+
measures: {{measuresString}},
|
|
278
|
+
filters: {{filtersString}},
|
|
279
|
+
highlights: {{highlightsString}},
|
|
280
|
+
}
|
|
281
|
+
const { data, isLoading, isError, error } = useExecuteQuery(queryProps);
|
|
282
|
+
<\/script>
|
|
283
|
+
<template>
|
|
284
|
+
<div>
|
|
285
|
+
<div v-if="isLoading">Loading...</div>
|
|
286
|
+
<div v-else-if="isError">Error: {{error.message}}</div>
|
|
287
|
+
<div v-else-if="data">Total Rows: {{data.rows.length}}</div>
|
|
288
|
+
</div>
|
|
289
|
+
</template>`,executePivotQueryTmpl:"Not implemented yet",pivotTableWidgetTmpl:"Not implemented yet"}},Q=(e,t)=>G[t][e].replace(/{{(.*?)Tmpl}}/g,(a,s)=>Q(`${s}Tmpl`,t)),L=(e,t)=>e.replace(/{{(.*?)}}/g,(r,a)=>a in t?t[a]:(console.warn(`Placeholder ${a} not found in data`),r)),E=(e,t,r="react")=>{const a=Q(e,r);return L(a,t)},y=`
|
|
290
|
+
`,b="UNKNOWN",ee=(e,t)=>{let r="";return r+=`measureFactory.customFormula(
|
|
291
|
+
`,r+=" ".repeat(t),r+=` '${h(e.title)}',
|
|
292
|
+
`,r+=" ".repeat(t),r+=` '${e.formula}',
|
|
293
|
+
`,r+=" ".repeat(t),r+=` {
|
|
294
|
+
`,Object.entries(e.context).forEach(([a,s])=>{const i=o.normalizeAttributeName(s.table||b,s.column||b,void 0,"DM");r+=" ".repeat(t),r+=` '${a.slice(1,-1)}': ${i},
|
|
295
|
+
`}),r+=" ".repeat(t),r+=` }
|
|
296
|
+
`,r+=" ".repeat(t),r+=")",r},te=(e,t)=>{const{level:r,table:a,column:s,agg:i,sort:n,title:d}=e;let l;return a&&s&&(l=o.normalizeAttributeName(a,s,r,"DM")),i&&a&&s&&d&&(l=`measureFactory.${o.DimensionalBaseMeasure.aggregationFromJAQL(i)}(${l}, '${h(d)}')`),n&&(l=`{column: ${l}, sortType: '${o.getSortType(n)}'}`),l?`${" ".repeat(t)}${l}`:b},re=(e,t)=>{const r=e.jaql().jaql;return"formula"in r?ee(r,t):y+te(r,t)},c=(e,t=0,r=!1)=>{if(!e)return"";if(typeof e=="string")return`'${h(e)}'`;if(e instanceof I)return re(e,t);let a="";return Array.isArray(e)?a+=`[${e.map(s=>c(s,t+2))}${e.length?y+" ".repeat(t+2):""}]`:(a+=`{${y}`,Object.entries(e).forEach(([s,i])=>{r&&(s=`'${h(s)}'`),a+=" ".repeat(t+2),Array.isArray(i)?a+=`${s}: [${i.map(n=>c(n,t+4,r))}${i.length?y+" ".repeat(t+2):""}]`:typeof i=="object"?a+=`${s}: ${c(i,t+2,r)}`:["number","boolean","undefined",null].includes(typeof i)?a+=`${s}: ${i}`:a+=`${s}: '${h(i)}'`,a+=`,${y}`}),a+=" ".repeat(t),a+="}"),a};function ae(e){return c(e,2)}function x(e){if(!e)throw new o.TranslatableError("errors.undefinedDataSource");let t;return typeof e=="object"&&"title"in e?t=e.title:t=e,J(t)}function O(e){const t=["measureFactory"];return Array.isArray(e)&&e.length>0&&t.push("filterFactory"),`import { ${t.join(", ")} } from '@sisense/sdk-data';`}const D=`
|
|
297
|
+
`,ie=(e,t)=>{if(e.composeCode)return`${D}${" ".repeat(t)}${e.composeCode}`;const r=e.jaql().jaql;return`${D}${" ".repeat(t)}filterFactory.customFilter(${c(r,t,!0)})`},se=(e,t=0)=>{if(!e)return"";let r="";return r+=`[${e.map(a=>ie(a,t+2))}${e.length?`
|
|
298
|
+
`+" ".repeat(t+2):""}]`,r},j=e=>{if(!e)return"";if(Array.isArray(e))return se(e,2);throw new o.TranslatableError("errors.filterRelationsNotSupported")},oe=["executeQueryByWidgetIdTmpl","widgetByIdTmpl"],ne="chartWidgetTmpl",le="pivotTableWidgetTmpl",de=e=>e,ue=(e,t,r)=>{const a={titleString:e.title,dataSourceString:x(e.dataSource),chartTypeString:de(e.chartType),dataOptionsString:ae(e.dataOptions),filtersString:j(e.filters),componentString:"ChartWidget",extraImportsString:O(e.filters||[])};return E(r,a,t)},ce=(e,t,r)=>{const a={titleString:e.title,dataSourceString:x(e.dataSource),dataOptionsString:c(e.dataOptions),componentString:"PivotTableWidget",extraImportsString:O(e.filters||[])};return E(r,a,t)},pe=({dashboardOid:e,widgetOid:t,uiFramework:r="react",chartType:a="table",includeChart:s=!0})=>{q(a);const i={dashboardOid:e,widgetOid:t},n=oe[Number(s)];return E(n,i,r)},me=({widgetProps:e,uiFramework:t="react"})=>{if(o.isChartWidgetProps(e))return q(e.chartType),ue(e,t,ne);if(o.isPivotTableWidgetProps(e))return ce(e,t,le);throw new o.TranslatableError("errors.otherWidgetTypesNotSupported")},ge=e=>({dataOptions:{columns:e.map(W)}}),fe=Object.freeze({convolution:{enabled:!0,selectedConvolutionType:"bySlicesCount",independentSlicesCount:7},lineWidth:{width:"bold"},markers:{enabled:!1},legend:{enabled:!1},yAxis:{gridLines:!1},xAxis:{gridLines:!1}}),M=Object.freeze({line:"line/spline",pie:"pie/donut",bar:"bar/stacked",column:"column/stackedcolumn"}),ye=(e,t)=>{const{axesMapping:r={},chartFamily:a}=t,s=e.reduce((n,d)=>(n[d.jaql.title]=d,n),{}),i=Object.entries(r).reduce((n,d)=>{const[l,m]=d;return n[`${l}`]=Array.isArray(m)?m.map(g=>{var S,T;const u=s[g.name];if(!u)return{column:{type:"",name:g.name}};const p=W(u);if(u.panel==="measures")return{column:p,sortType:"sortNone"};if(o.isDatetime(p.type)){const v=(T=(S=u.format)==null?void 0:S.mask)==null?void 0:T[u.jaql.level];if(v)return{column:p,dateFormat:v}}return p}):m,n},{});switch(a){case"cartesian":return f({category:[],value:[],breakBy:[]},i);case"categorical":return f({category:[],value:[]},i);case"scatter":return Object.keys(i).forEach(n=>{i[`${n}`]=i[`${n}`][0]}),i;case"scattermap":return Object.keys(i).forEach(n=>{n!=="geo"&&(i[`${n}`]=i[`${n}`][0])}),i;case"table":return Object.keys(i).length===0?ge(e).dataOptions:i;case"boxplot":case"areamap":case"indicator":default:return i}},P=(e,t)=>{var r,a,s,i;return t==="x"?(a=(r=e.axesMapping.category)!=null?r:e.axesMapping.x)==null?void 0:a.map(n=>n.name).join(", "):(i=(s=e.axesMapping.value)!=null?s:e.axesMapping.y)==null?void 0:i.map(n=>n.name).join(", ")},he=(e,t,r=!0)=>{const a=ye(e,t);let s;return r&&t.chartType in M?s=o.merge(o.merge(fe,{subtype:M[t.chartType]}),{legend:{enabled:!0,position:"right"},yAxis:{title:{enabled:!0,text:P(t,"y")}},xAxis:{title:{enabled:!0,text:P(t,"x")}}}):s=o.getDefaultStyleOptions(),{dataOptions:a,chartStyleOptions:s}},Se=e=>"chartType"in e?e:{chartType:"table",chartFamily:"table",axesMapping:{}},Te=e=>e.map(t=>o.createFilterFromJaql(t.jaql)),ve=e=>e.reduce((t,r)=>{if((r.panel==="scope"||r.jaql.filter)&&t.metadataFilters.push(o.cloneDeep(r)),r.panel!=="scope"){const a=o.cloneDeep(r);delete a.jaql.filter,t.metadataColumns.push(a)}return t},{metadataColumns:[],metadataFilters:[]}),Ee=(e,t)=>{if(!Z(e))try{const{useCustomizedStyleOptions:r=!1}=t||{},{jaql:a,chartRecommendations:s,queryTitle:i}=e,{metadata:n,datasource:{title:d,id:l,type:m="elasticube"}}=a,g=Se(s),u=g.chartType.toLowerCase(),p={cornerRadius:"Small",header:{renderToolbar:()=>null}},{metadataColumns:S,metadataFilters:T}=ve(n),v=Te(T),{dataOptions:F,chartStyleOptions:_}=he(S,g,r),N=f(f({},_),p);return{widgetType:"chart",id:i,title:i,chartType:u,dataSource:{title:d,id:l,type:m},dataOptions:F,filters:v,styleOptions:N}}catch(r){console.error(r);return}},A=(e,t)=>Ee(e,t),be=e=>$(e)?pe(e):me(e),xe=Object.freeze(Object.defineProperty({__proto__:null,toWidgetCode:be,toWidgetProps:A},Symbol.toStringTag,{value:"Module"}));exports.EMPTY_EXPANDED_QUERY_MODEL=z;exports.EMPTY_SIMPLE_QUERY_MODEL=K;exports.capitalizeFirstLetter=V;exports.generateCode=E;exports.isByIdWidgetCodeParams=$;exports.isClientSideWidgetCodeParams=U;exports.populatePlaceholders=L;exports.sanitizeDimensionId=X;exports.stringifyDataSource=x;exports.stringifyExtraImports=O;exports.stringifyFilters=j;exports.stringifyProps=c;exports.toWidgetProps=A;exports.validateQueryModel=H;exports.widgetComposer=xe;
|