@qrvey/utils 1.5.0-3 → 1.5.0-4

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 (30) hide show
  1. package/README.md +1 -1
  2. package/dist/charts/adapters/endpointData.d.ts +90 -0
  3. package/dist/charts/adapters/endpointData.js +511 -0
  4. package/dist/charts/adapters/endpointDataGet.d.ts +14 -0
  5. package/dist/charts/adapters/endpointDataGet.js +428 -0
  6. package/dist/charts/adapters/endpointDataValidators.d.ts +4 -0
  7. package/dist/charts/adapters/endpointDataValidators.js +54 -0
  8. package/dist/charts/adapters/index.d.ts +3 -0
  9. package/dist/charts/adapters/index.js +3 -0
  10. package/dist/charts/index.d.ts +1 -0
  11. package/dist/charts/index.js +1 -0
  12. package/dist/cjs/charts/adapters/endpointData.d.ts +90 -0
  13. package/dist/cjs/charts/adapters/endpointData.js +517 -0
  14. package/dist/cjs/charts/adapters/endpointDataGet.d.ts +14 -0
  15. package/dist/cjs/charts/adapters/endpointDataGet.js +444 -0
  16. package/dist/cjs/charts/adapters/endpointDataValidators.d.ts +4 -0
  17. package/dist/cjs/charts/adapters/endpointDataValidators.js +61 -0
  18. package/dist/cjs/charts/adapters/index.d.ts +3 -0
  19. package/dist/cjs/charts/adapters/index.js +19 -0
  20. package/dist/cjs/charts/index.d.ts +1 -0
  21. package/dist/cjs/charts/index.js +1 -0
  22. package/dist/cjs/constants/Charts.Const.d.ts +1 -0
  23. package/dist/cjs/constants/Charts.Const.js +1 -0
  24. package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +1 -0
  25. package/dist/cjs/globalization/labels/common/I18N_COMMON.js +1 -0
  26. package/dist/constants/Charts.Const.d.ts +1 -0
  27. package/dist/constants/Charts.Const.js +1 -0
  28. package/dist/globalization/interfaces/common/II18nCommon.d.ts +1 -0
  29. package/dist/globalization/labels/common/I18N_COMMON.js +1 -0
  30. package/package.json +1 -1
@@ -0,0 +1,517 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configChartData = exports.configMetricData = exports.configSetup = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const filters_1 = require("../../filters");
6
+ const format_1 = require("../../format");
7
+ const general_1 = require("../../general");
8
+ const endpointDataGet_1 = require("./endpointDataGet");
9
+ const endpointDataValidators_1 = require("./endpointDataValidators");
10
+ function makeBodyRequest(body, filters = []) {
11
+ if (!body)
12
+ return;
13
+ const category = (0, general_1._get)(body, "layerList[0].category");
14
+ if (category && category.bucketId)
15
+ category.id = category.bucketId;
16
+ const distribution = (0, general_1._get)(body, "layerList[0].distribution");
17
+ const categoryId = category
18
+ ? category.id
19
+ : distribution
20
+ ? distribution.id
21
+ : null;
22
+ const dataType = (0, general_1._get)(body, "layerList[0].category.type");
23
+ const maxDataPoints = (0, general_1._get)(body, "globalSettings.maxNumDataPoints", 50);
24
+ const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
25
+ const sortOption = {
26
+ sortBy: (0, endpointDataGet_1.getValidSortingType)(body) === "Label" ? "CATEGORY" : "VALUE",
27
+ sortDirection: (sorting.order || "ASC").toUpperCase(),
28
+ };
29
+ let label;
30
+ if (categoryId) {
31
+ label = {
32
+ questionid: categoryId,
33
+ qrveyid: (category || distribution).qrveyid || body.qrveyid,
34
+ property: (category || distribution).property || body.property,
35
+ type: (category || distribution).type || body.type,
36
+ };
37
+ }
38
+ if (body.layerList)
39
+ return body.layerList.reduce(function (charts, layer, index) {
40
+ if (index > 0 && !(0, general_1._get)(layer, "combopt.label"))
41
+ return charts;
42
+ let chart;
43
+ if (index > 0 && layer.combopt.label == "MULTI") {
44
+ chart = { type: "MULTI_SERIE" };
45
+ }
46
+ else if (index > 0 &&
47
+ ["TREND", "REFERENCE"].includes(layer.combopt.label)) {
48
+ chart =
49
+ layer.combopt.label == "TREND"
50
+ ? (0, endpointDataGet_1.getTrendBody)(layer)
51
+ : (0, endpointDataGet_1.getRefenceBody)(layer);
52
+ if (typeof chart.value == "object" && !chart.value.qrveyid)
53
+ chart.value.qrveyid = body.qrveyid;
54
+ }
55
+ else if ((0, general_1._get)(layer, "combopt.label") !== "SMALL_MULTIPLES") {
56
+ if (layer.value)
57
+ layer.value.qrveyid = layer.value.qrveyid || body.qrveyid;
58
+ chart = (0, endpointDataGet_1.getLayerBody)(layer, body.dateGroup || layer.dateGroup, body.qrveyid);
59
+ if (chart) {
60
+ chart.labelId = categoryId;
61
+ chart.dataType = dataType;
62
+ // this object is for new datalink feature
63
+ if (chart.value)
64
+ chart.label = label;
65
+ if (layer.type === "BOXWHISKER_CHART") {
66
+ if (!dataType) {
67
+ delete chart.label;
68
+ delete chart.labelId;
69
+ }
70
+ if (distribution) {
71
+ chart.distribution = {
72
+ aggregate: chart.aggregate,
73
+ questionid: distribution.id || distribution.bucketId,
74
+ qrveyid: body.qrveyid,
75
+ type: distribution.type,
76
+ };
77
+ }
78
+ delete chart.aggregate;
79
+ }
80
+ if ((layer.type == "WORD_CLOUD" ||
81
+ (layer.type == "GEO_CHART" &&
82
+ (0, general_1._get)(layer, "mapType.label") == "DOT")) &&
83
+ !chart.value) {
84
+ chart.label = label;
85
+ if (label.type !== "BUCKET") {
86
+ // AN-7111 so far charts doesn't support bucket columns as value
87
+ chart.value = label;
88
+ }
89
+ }
90
+ if ([constants_1.CHART_TYPE.GEO_CHART, constants_1.CHART_TYPE.GEO_CHART_BUBBLE].includes(layer.type)) {
91
+ chart.aggFilters = (0, endpointDataGet_1.getAggFiltersResults)(filters, [
92
+ Object.assign(Object.assign({}, chart.value), { aggregate: chart.aggregate }),
93
+ ]);
94
+ if (chart.label)
95
+ chart.property = chart.label.property;
96
+ }
97
+ }
98
+ }
99
+ if (chart) {
100
+ chart.id = index;
101
+ if ((0, general_1._get)(body, "globalSettings.maxDataPoints", false))
102
+ chart.maxDataPoints = maxDataPoints;
103
+ chart.sortOption = sortOption;
104
+ const bucketData = category;
105
+ if (bucketData && bucketData.type === "BUCKET" && bucketData.bucketId) {
106
+ chart.labelBucketId = bucketData.bucketId;
107
+ delete chart.label; // deleted unnecessary chart label property in buckets
108
+ }
109
+ charts.push(chart);
110
+ }
111
+ return charts;
112
+ }, []);
113
+ }
114
+ function makeBodyRequestU(body, filters, newModel = false) {
115
+ var _a, _b, _c;
116
+ if (!body)
117
+ return;
118
+ const pSmallMultiple = (0, endpointDataGet_1.getSmallMultipleBody)(body.layerList.find((ly) => (0, general_1._get)(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
119
+ let pSummaries = (0, endpointDataGet_1.getSummariesBody)((0, general_1._get)(body, "layerList[0]"), body);
120
+ const pCategory = (0, endpointDataGet_1.getCategoryBody)((0, general_1._get)(body, "layerList[0]"), body);
121
+ const pPivot = (0, endpointDataGet_1.getPivotBody)((0, general_1._get)(body, "layerList[0]"), body);
122
+ const aggFilters = (0, endpointDataGet_1.getAggFiltersResults)(filters, pSummaries);
123
+ let requestBody = [];
124
+ if (body.layerList) {
125
+ requestBody = body.layerList.reduce(function (charts, layer, index) {
126
+ if (index <= 0 || !(0, general_1._get)(layer, "combopt.label"))
127
+ return charts;
128
+ let chart;
129
+ switch (layer.combopt.label) {
130
+ case "TREND":
131
+ chart = (0, endpointDataGet_1.getTrendBody)(layer);
132
+ break;
133
+ case "REFERENCE":
134
+ chart = (0, endpointDataGet_1.getRefenceBodyU)(layer, body);
135
+ break;
136
+ case "COMBO":
137
+ chart = (0, endpointDataGet_1.getComboBody)(layer, body, filters, newModel);
138
+ break;
139
+ case "MULTI":
140
+ chart = {
141
+ type: layer.combopt.label,
142
+ };
143
+ break;
144
+ }
145
+ if (chart)
146
+ charts.push(chart);
147
+ return charts;
148
+ }, []);
149
+ }
150
+ if (newModel) {
151
+ const dimensions = [];
152
+ if (pSmallMultiple)
153
+ dimensions.push(pSmallMultiple);
154
+ if (pCategory)
155
+ dimensions.push(pCategory);
156
+ if (pPivot)
157
+ dimensions.push(pPivot);
158
+ if (!pSummaries[0].aggregate && !((_c = (_b = (_a = pCategory.sortOption) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.hidden)) {
159
+ let sortValue = {};
160
+ if ((0, general_1._get)(pCategory, "sortOption.sortBy") === "VALUE") {
161
+ sortValue = Object.assign({}, pCategory.sortOption);
162
+ sortValue.sortBy = "CATEGORY";
163
+ pCategory.sortOption = {};
164
+ }
165
+ const newSummary = Object.assign(pSummaries[0], {
166
+ maxDataPoints: body.globalSettings.maxNumValuePoints,
167
+ });
168
+ if (!newSummary.sortOption)
169
+ newSummary.sortOption = sortValue;
170
+ dimensions.push(newSummary);
171
+ pSummaries = [];
172
+ }
173
+ // TODO: Mejorar estructura para que la propiedad venga directamente del chart builder
174
+ if (body.type == "HEATMAP_CHART" &&
175
+ pSummaries &&
176
+ pSummaries[0].calculations) {
177
+ const direction = (0, general_1._get)(body.globalSettings, "calculation_direction", "Across") === "Down"
178
+ ? "vertical"
179
+ : "horizontal";
180
+ pSummaries[0].calculations.direction = direction;
181
+ }
182
+ requestBody.unshift({
183
+ dimensions: dimensions,
184
+ summaries: pSummaries,
185
+ aggFilters: aggFilters,
186
+ });
187
+ }
188
+ else {
189
+ requestBody.unshift({
190
+ category: pCategory,
191
+ summaries: pSummaries,
192
+ aggFilters: aggFilters,
193
+ pivot: pPivot,
194
+ });
195
+ }
196
+ return requestBody;
197
+ }
198
+ function configSetup(config) {
199
+ var _a;
200
+ const cfg = (0, general_1.cloneDeep)(config || {});
201
+ cfg.panel = cfg.panel || {};
202
+ const body = (0, general_1.getAttribute)(cfg.panel, "body") || {};
203
+ const header = (0, general_1.getAttribute)(cfg.panel, "header") || {};
204
+ const footer = (0, general_1.getAttribute)(cfg.panel, "footer") || {};
205
+ let filterSettings = header.filter;
206
+ filterSettings = {
207
+ button: {
208
+ display: (0, general_1._get)(header.filter, "button.display", (0, general_1._get)(header, "filter", false)),
209
+ disable: (0, general_1._get)(header.filter, "button.disable", false),
210
+ },
211
+ card: {
212
+ display: (0, general_1._get)(header.filter, "card.display", true),
213
+ addFilter: (0, general_1._get)(header.filter, "card.addFilter", true),
214
+ editFilter: (0, general_1._get)(header.filter, "card.editFilter", true),
215
+ removeFilter: (0, general_1._get)(header.filter, "card.removeFilter", true),
216
+ },
217
+ };
218
+ cfg.panel.styles = cfg.panel.styles || {};
219
+ const ctx = {
220
+ config: {
221
+ id: cfg.id,
222
+ data: cfg.data,
223
+ type: cfg.type,
224
+ domain: cfg.domain,
225
+ model: (0, general_1.getAttribute)(cfg, "model"),
226
+ tab_id: (0, general_1.getAttribute)(cfg, "tab_id"),
227
+ app_id: (0, general_1.getAttribute)(cfg, "app_id"),
228
+ api_key: (0, general_1.getAttribute)(cfg, "api_key"),
229
+ user_id: (0, general_1.getAttribute)(cfg, "user_id"),
230
+ view_id: (0, general_1.getAttribute)(cfg, "view_id"),
231
+ page_id: (0, general_1.getAttribute)(cfg, "page_id"),
232
+ chart_id: (0, general_1.getAttribute)(cfg, "chart_id"),
233
+ qv_token: (0, general_1.getAttribute)(cfg, "qv_token"),
234
+ qrvey_id: (0, general_1.getAttribute)(cfg, "qrvey_id"),
235
+ question: (0, general_1.getAttribute)(cfg, "question"),
236
+ metric_id: (0, general_1.getAttribute)(cfg, "metric_id"),
237
+ summary_id: (0, general_1.getAttribute)(cfg, "summary_id"),
238
+ formulaType: (0, general_1._get)(cfg, "question.formulaType"),
239
+ summary_type: (0, general_1.getAttribute)(cfg, "summary_type"),
240
+ custom_tokens: (0, general_1.getAttribute)(cfg, "custom_tokens"),
241
+ section: (0, general_1.getAttribute)(cfg, "section") || "ANYWHERE",
242
+ panel_view: (0, general_1.getAttribute)(cfg, "panel_view") || "ANYWHERE",
243
+ previewFilters: cfg.previewFilters || [],
244
+ filterData: !(0, general_1.isEmpty)(cfg.filterData)
245
+ ? cfg.filterData
246
+ : { scopes: [], version: filters_1.FILTER_STRUCTURE_VERSION },
247
+ i18n: cfg.i18n,
248
+ visibleFilters: {},
249
+ appliedFilters: {},
250
+ customDrillLogic: [],
251
+ isFromAN: cfg.isFromAN,
252
+ editable: cfg.editable,
253
+ inBuilder: cfg.inBuilder,
254
+ clickable: cfg.clickable,
255
+ userFilters: cfg.userFilters,
256
+ customdrill: cfg.customdrill,
257
+ widgetConfig: cfg.widgetConfig,
258
+ drilldowns: cfg.drilldowns || {},
259
+ filterPermissions: cfg.filterPermissions,
260
+ chartBuilderConfig: cfg.chartBuilderConfig,
261
+ other_config: (0, general_1.getAttribute)(cfg, "other_config"),
262
+ predefined_filters: (0, general_1.getAttribute)(cfg, "predefined_filters"),
263
+ locale: (0, format_1.getLang)((_a = cfg === null || cfg === void 0 ? void 0 : cfg.i18n) === null || _a === void 0 ? void 0 : _a.locale) || cfg.locale,
264
+ lang: (0, format_1.chooseLang)(cfg),
265
+ panel: {
266
+ header: {
267
+ menu: header.menu,
268
+ filter: filterSettings,
269
+ draggable: header.draggable,
270
+ title_prefix: header.title_prefix,
271
+ fit_panel: header.fit_panel || false,
272
+ visible: (0, general_1._hasProperty)(header, "visible") ? header.visible : true,
273
+ ui: {
274
+ isFiltered: false,
275
+ isDisplayReady: false,
276
+ isScrollableXY: false,
277
+ },
278
+ externalDownload: header.externalDownload,
279
+ },
280
+ body: {
281
+ popup: body.popup,
282
+ tooltip: body.tooltip,
283
+ hasTimeout: cfg.type === "CHART",
284
+ hasOverlay: (0, general_1._hasProperty)(body, "hasOverlay") ? body.hasOverlay : true,
285
+ stylesTheme: {
286
+ original_match_color: (0, general_1._get)(cfg, "panel.styles.match_color", (0, general_1._get)(cfg, "stylesTheme.match_color")),
287
+ match_color: undefined,
288
+ },
289
+ ui: {
290
+ isLoading: true,
291
+ settingsStyle: cfg.panel.styles,
292
+ timeoutMessage: `Calculating ${(cfg.type || "").toLowerCase()}. This process may take a while.`,
293
+ },
294
+ },
295
+ footer: {
296
+ visible: (0, general_1._hasProperty)(footer, "visible") ? footer.visible : false,
297
+ },
298
+ },
299
+ },
300
+ data: {},
301
+ scopes: {},
302
+ baseConfig: {},
303
+ customdrills: [],
304
+ };
305
+ ctx.baseConfig = {
306
+ pb_version: cfg.pb_version,
307
+ lang: ctx.config.lang,
308
+ domain: ctx.config.domain,
309
+ app_id: ctx.config.app_id,
310
+ api_key: ctx.config.api_key,
311
+ user_id: ctx.config.user_id,
312
+ qrvey_id: ctx.config.qrvey_id,
313
+ qv_token: ctx.config.qv_token,
314
+ custom_tokens: ctx.config.custom_tokens,
315
+ };
316
+ ctx.scopes = (0, filters_1.getAvailableScopes)(Object.assign(Object.assign({}, (0, filters_1.getAvailableScopesIDsByConfig)(ctx.config)), { predefinedScopes: [{ label: filters_1.FILTER_SCOPE.DATA, id: ctx.config.qrvey_id }] }));
317
+ return ctx;
318
+ }
319
+ exports.configSetup = configSetup;
320
+ function updateDimensionsByChart(data, model) {
321
+ var _a, _b, _c, _d;
322
+ if (!((_a = data === null || data === void 0 ? void 0 : data.globalSettings) === null || _a === void 0 ? void 0 : _a.chartVersion) &&
323
+ ((_b = data === null || data === void 0 ? void 0 : data.globalSettings) === null || _b === void 0 ? void 0 : _b.match_colors)) {
324
+ data.globalSettings.match_colors = false;
325
+ }
326
+ if (((_c = data === null || data === void 0 ? void 0 : data.globalSettings) === null || _c === void 0 ? void 0 : _c.match_colors) &&
327
+ (0, endpointDataValidators_1.hasMinorVersion)(((_d = data === null || data === void 0 ? void 0 : data.globalSettings) === null || _d === void 0 ? void 0 : _d.chartVersion) || "1.0", "2.0")) {
328
+ data.globalSettings.match_colors = false;
329
+ data.globalSettings.chartVersion = "2.0";
330
+ }
331
+ const questions = (0, general_1._get)(model, "questions.data");
332
+ if (!(0, general_1.isEmpty)(questions)) {
333
+ if (!(0, general_1.isEmpty)((0, general_1._get)(data, "chart.fields"))) {
334
+ Object.keys(data.chart.fields).forEach((field) => {
335
+ data.chart.fields[field].forEach((column, index) => {
336
+ const question = questions.find((q) => q.id === column.data.id);
337
+ if (!(0, general_1.isEmpty)(question) && question.text !== column.data.text) {
338
+ if (column.data.text === column.data.label)
339
+ data.chart.fields[field][index].data.label = question.text;
340
+ if (column.data.text === column.label)
341
+ data.chart.fields[field][index].label = question.text;
342
+ data.chart.fields[field][index].data.text = question.text;
343
+ }
344
+ });
345
+ });
346
+ }
347
+ if (!(0, general_1.isEmpty)((0, general_1._get)(data, "layerList"))) {
348
+ data.layerList.forEach((layer, index) => {
349
+ if (!(0, general_1.isEmpty)(layer.category)) {
350
+ const question = questions.find((q) => q.id === layer.category.id);
351
+ if (!(0, general_1.isEmpty)(question)) {
352
+ data.layerList[index].category.text = question.text;
353
+ }
354
+ }
355
+ if (!(0, general_1.isEmpty)(layer.value)) {
356
+ const question = questions.find((q) => q.id === layer.value.id);
357
+ if (!(0, general_1.isEmpty)(question)) {
358
+ data.layerList[index].value.text = question.text;
359
+ }
360
+ }
361
+ if (!(0, general_1.isEmpty)((0, general_1._get)(layer, "multiserie.serie"))) {
362
+ const question = questions.find((q) => q.id === layer.multiserie.serie.id);
363
+ if (!(0, general_1.isEmpty)(question)) {
364
+ data.layerList[index].multiserie.serie.text = question.text;
365
+ }
366
+ }
367
+ });
368
+ }
369
+ if (!(0, general_1.isEmpty)((0, general_1._get)(data, "v2.dimensions"))) {
370
+ Object.keys(data.v2.dimensions).forEach((dimension) => {
371
+ data.v2.dimensions[dimension].forEach((column, index) => {
372
+ const question = questions.find((q) => q.id === column.id);
373
+ if (!(0, general_1.isEmpty)(question) && question.text !== column.text) {
374
+ if (column.text === column.label)
375
+ data.v2.dimensions[dimension][index].label = question.text;
376
+ data.v2.dimensions[dimension][index].text = question.text;
377
+ }
378
+ });
379
+ });
380
+ }
381
+ }
382
+ return data;
383
+ }
384
+ function configMetricData(metricObj //
385
+ ) {
386
+ var _a, _b;
387
+ const body = {};
388
+ const data = metricObj.data;
389
+ try {
390
+ metricObj.logic = (0, filters_1.FDToLogic)(Object.assign({}, (0, filters_1.excludeFiltersByAggregateColumn)((_a = metricObj === null || metricObj === void 0 ? void 0 : metricObj.defaultFilters) === null || _a === void 0 ? void 0 : _a.data)));
391
+ body.logic = (_b = metricObj.logic) !== null && _b !== void 0 ? _b : {};
392
+ body.qrveyid = data.dataSet.qrveyid;
393
+ body.apptype = data.dataSet.appType;
394
+ body.valueDetails = {
395
+ id: data.value.id,
396
+ aggType: data.valueAggregate.label,
397
+ dataType: data.value.type,
398
+ property: data.value.property,
399
+ };
400
+ }
401
+ catch (e) {
402
+ return false;
403
+ }
404
+ if (data.dateColumn) {
405
+ const dateColum = data.dateColumn.id;
406
+ const timeZoneOffset = 0;
407
+ // TIME PERIOD
408
+ try {
409
+ const timePeriod = data.timePeriod.label;
410
+ body.timePeriodDetails = {
411
+ id: dateColum,
412
+ type: timePeriod,
413
+ dataType: data.dateColumn.type,
414
+ timeZoneOffset,
415
+ };
416
+ if (timePeriod === "CUSTOM_RANGE") {
417
+ const type = data.timePeriodCustomRange.label;
418
+ body.timePeriodDetails.customRangeType = type;
419
+ body.timePeriodDetails.range = {};
420
+ if ("AFTER" === type) {
421
+ if (!data.timePeriodDate)
422
+ throw 0;
423
+ body.timePeriodDetails.range.from = data.timePeriodDate;
424
+ }
425
+ else if ("BEFORE" === type) {
426
+ if (!data.timePeriodDate)
427
+ throw 0;
428
+ body.timePeriodDetails.range.to = data.timePeriodDate;
429
+ }
430
+ else {
431
+ if (!data.timePeriodDate || !data.timePeriodEndDate)
432
+ throw 0;
433
+ body.timePeriodDetails.range.from = data.timePeriodDate;
434
+ body.timePeriodDetails.range.to = data.timePeriodEndDate;
435
+ }
436
+ }
437
+ }
438
+ catch (e) {
439
+ delete body.timePeriodDetails;
440
+ }
441
+ try {
442
+ const comparison = data.comparison.label;
443
+ body.comparisonDetails = {
444
+ id: dateColum,
445
+ type: comparison,
446
+ dataType: data.dateColumn.type,
447
+ timeZoneOffset,
448
+ };
449
+ if (comparison === "CUSTOM_RANGE") {
450
+ const type = data.comparisonCustomRange.label;
451
+ body.comparisonDetails.customRangeType = type;
452
+ body.comparisonDetails.range = {};
453
+ if ("AFTER" === type) {
454
+ if (!data.comparisonDate)
455
+ throw 0;
456
+ body.comparisonDetails.range.from = data.comparisonDate;
457
+ }
458
+ else if ("BEFORE" === type) {
459
+ if (!data.comparisonDate)
460
+ throw 0;
461
+ body.comparisonDetails.range.to = data.comparisonDate;
462
+ }
463
+ else {
464
+ if (!data.comparisonDate || !data.comparisonEndDate)
465
+ throw 0;
466
+ body.comparisonDetails.range.from = data.comparisonDate;
467
+ body.comparisonDetails.range.to = data.comparisonEndDate;
468
+ }
469
+ }
470
+ }
471
+ catch (e) {
472
+ delete body.comparisonDetails;
473
+ }
474
+ }
475
+ return body;
476
+ }
477
+ exports.configMetricData = configMetricData;
478
+ function configChartData(chartData, model, setup) {
479
+ var _a, _b;
480
+ const ctx = configSetup(setup);
481
+ chartData = updateDimensionsByChart(chartData, model);
482
+ if (!chartData.defaultFilters)
483
+ chartData.defaultFilters = {};
484
+ if (!(0, general_1.isEmpty)(chartData.defaultFilters) &&
485
+ (0, general_1.isEmpty)((0, general_1._get)(chartData.defaultFilters, "data.version"))) {
486
+ chartData.defaultFilters = {
487
+ data: (0, filters_1.adaptFilterData)(chartData.defaultFilters),
488
+ };
489
+ }
490
+ const logic = (0, filters_1.FDToLogic)(Object.assign({}, (0, filters_1.excludeFiltersByAggregateColumn)(chartData.defaultFilters.data)));
491
+ const chart = {
492
+ data: chartData,
493
+ type: chartData.layerList[0].type,
494
+ };
495
+ if ((0, endpointDataValidators_1.isNotValid)((0, general_1._get)(chartData, "layerList[0]")))
496
+ return;
497
+ let drillData = {};
498
+ const customData = {};
499
+ const drilldowns = ctx.config.drilldowns[(0, endpointDataGet_1.getDrilldownId)(ctx, chartData)] || [];
500
+ if (drilldowns.length > 0)
501
+ drillData = Object.assign({}, drilldowns[drilldowns.length - 1]);
502
+ if (drillData.chart)
503
+ customData.chart = Object.assign({}, drillData.chart);
504
+ if (((_a = drillData.filters) === null || _a === void 0 ? void 0 : _a.length) > 0)
505
+ customData.filters = [...drillData.filters];
506
+ const validEndPoint = (0, endpointDataValidators_1.validChartTypeWithEndPoint)(chart.type);
507
+ const bodyRequest = customData.chart || chartData;
508
+ const filterRequest = (_b = (0, filters_1.UIToOldLogic)(chartData.defaultFilters.data)) === null || _b === void 0 ? void 0 : _b.logic;
509
+ const charts = validEndPoint
510
+ ? makeBodyRequestU(bodyRequest, filterRequest, true)
511
+ : makeBodyRequest(bodyRequest, filterRequest);
512
+ return {
513
+ charts,
514
+ logic,
515
+ };
516
+ }
517
+ exports.configChartData = configChartData;
@@ -0,0 +1,14 @@
1
+ import { OLD_IFilterLogic, IFBFilterAggregate } from "../../filters";
2
+ export declare function getDrilldownId(ctx: any, data: any): string;
3
+ export declare function getPivotBody(layer: any, body: any): any;
4
+ export declare function getValidSortingType(body: any): "Value" | "Label";
5
+ export declare function getCategoryBody(layer: any, body: any): any;
6
+ export declare function getComboBody(layer: any, body: any, filters: any, newModel?: boolean): any;
7
+ export declare function getSmallMultipleBody(layer: any, body: any): any;
8
+ export declare function getAggFiltersResults(logics?: OLD_IFilterLogic[], summaries?: any[]): IFBFilterAggregate;
9
+ export declare function getRefenceBody(layer: any): any;
10
+ export declare function getTrendBody(layer: any): any;
11
+ export declare function getRefenceBodyU(layer: any, body: any): any;
12
+ export declare function getLayerBody(layer: any, dateGroup: any, qrveyid: any): any;
13
+ export declare function setDateGroup(column: any, body: any, obj: any): void;
14
+ export declare function getSummariesBody(layer: any, body: any): any;