@qrvey/utils 1.5.0-1 → 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 (52) 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/column_format/helpers/defineTableChartFormat.js +19 -10
  23. package/dist/cjs/constants/Charts.Const.d.ts +1 -0
  24. package/dist/cjs/constants/Charts.Const.js +1 -0
  25. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
  26. package/dist/cjs/filters/helpers/getTokensFromFilters.js +9 -4
  27. package/dist/cjs/globalization/interfaces/II18nResource.d.ts +2 -0
  28. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderFormatValues.d.ts +1 -0
  29. package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +2 -0
  30. package/dist/cjs/globalization/interfaces/tabular_view/II18nTabularView.d.ts +4 -0
  31. package/dist/cjs/globalization/interfaces/tabular_view/II18nTabularView.js +2 -0
  32. package/dist/cjs/globalization/labels/I18N_DEFAULT.js +2 -0
  33. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +1 -0
  34. package/dist/cjs/globalization/labels/common/I18N_COMMON.js +2 -0
  35. package/dist/cjs/globalization/labels/tabular_view/I18N_TABULAR_VIEW.d.ts +2 -0
  36. package/dist/cjs/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +7 -0
  37. package/dist/column_format/helpers/defineTableChartFormat.js +19 -10
  38. package/dist/constants/Charts.Const.d.ts +1 -0
  39. package/dist/constants/Charts.Const.js +1 -0
  40. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
  41. package/dist/filters/helpers/getTokensFromFilters.js +9 -4
  42. package/dist/globalization/interfaces/II18nResource.d.ts +2 -0
  43. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderFormatValues.d.ts +1 -0
  44. package/dist/globalization/interfaces/common/II18nCommon.d.ts +2 -0
  45. package/dist/globalization/interfaces/tabular_view/II18nTabularView.d.ts +4 -0
  46. package/dist/globalization/interfaces/tabular_view/II18nTabularView.js +1 -0
  47. package/dist/globalization/labels/I18N_DEFAULT.js +2 -0
  48. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +1 -0
  49. package/dist/globalization/labels/common/I18N_COMMON.js +2 -0
  50. package/dist/globalization/labels/tabular_view/I18N_TABULAR_VIEW.d.ts +2 -0
  51. package/dist/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +4 -0
  52. package/package.json +1 -1
@@ -0,0 +1,444 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSummariesBody = exports.setDateGroup = exports.getLayerBody = exports.getRefenceBodyU = exports.getTrendBody = exports.getRefenceBody = exports.getAggFiltersResults = exports.getSmallMultipleBody = exports.getComboBody = exports.getCategoryBody = exports.getValidSortingType = exports.getPivotBody = exports.getDrilldownId = void 0;
4
+ const columns_1 = require("../../columns");
5
+ const filters_1 = require("../../filters");
6
+ const general_1 = require("../../general");
7
+ const endpointDataValidators_1 = require("./endpointDataValidators");
8
+ function getDrilldownId(ctx, data) {
9
+ return !ctx.config.isFromAN
10
+ ? ctx.config.id || data.chartid || data.chart_id
11
+ : data.chartid || data.chart_id;
12
+ }
13
+ exports.getDrilldownId = getDrilldownId;
14
+ function getPivotBody(layer, body) {
15
+ const value = (0, general_1._get)(layer, "value");
16
+ const pivot = (0, general_1._get)(layer, "pivot", (0, general_1._get)(layer, "multiserie.serie"));
17
+ const type = (0, general_1._get)(layer, "type", "");
18
+ let obj;
19
+ if ((type === "HEATMAP_CHART" || !(0, general_1._get)(body, "isDrillDown")) && pivot) {
20
+ const uSorting = (0, general_1._get)(pivot, "sorting");
21
+ const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
22
+ let pSortOption = {
23
+ sortBy: uSorting || getValidSortingType(body) === "Label"
24
+ ? "CATEGORY"
25
+ : "VALUE",
26
+ sortDirection: ((uSorting && uSorting.order) ||
27
+ sorting.order ||
28
+ "ASC").toUpperCase(),
29
+ };
30
+ /** TODO: Remove line on implement universal sorting on Heatmap */
31
+ pSortOption =
32
+ value && value.calculation
33
+ ? { sortBy: "CATEGORY", sortDirection: "ASC" }
34
+ : pSortOption;
35
+ const maxDataPoints = pivot.type !== "DATE"
36
+ ? (0, general_1._get)(layer, "multiserie.maxDataPoints")
37
+ ? (0, general_1._get)(layer, "multiserie.maxNumDataPoints", 50)
38
+ : undefined
39
+ : 50;
40
+ obj = {
41
+ linkid: pivot.linkid,
42
+ maxDataPoints: maxDataPoints,
43
+ property: pivot.property,
44
+ qrveyid: pivot.qrveyid || body.qrveyid,
45
+ questionid: pivot.id || pivot.bucketId,
46
+ sortOption: pSortOption,
47
+ type: pivot.type,
48
+ };
49
+ setDateGroup(pivot, pivot, obj);
50
+ }
51
+ return obj;
52
+ }
53
+ exports.getPivotBody = getPivotBody;
54
+ function getValidSortingType(body) {
55
+ const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
56
+ const type = (0, general_1._get)(body, "layerList[0].type");
57
+ const notAllowValue = type === "HEATMAP_CHART" && (0, general_1._get)(body, "layerList[0].pivot");
58
+ return !sorting.type || sorting.type == "Label" || notAllowValue
59
+ ? "Label"
60
+ : "Value";
61
+ }
62
+ exports.getValidSortingType = getValidSortingType;
63
+ function getCategoryBody(layer, body) {
64
+ var _a;
65
+ const maxDataPoints = (0, general_1._get)(body, "globalSettings.maxNumDataPoints");
66
+ const category = (0, general_1._get)(layer, "category");
67
+ if (category && category.bucketId)
68
+ category.id = category.bucketId;
69
+ const categoryId = category ? category.id : null;
70
+ const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
71
+ const pSortOption = {
72
+ sortBy: ((_a = sorting === null || sorting === void 0 ? void 0 : sorting.column) === null || _a === void 0 ? void 0 : _a.isHidden)
73
+ ? "VALUE"
74
+ : getValidSortingType(body) === "Label"
75
+ ? "CATEGORY"
76
+ : "VALUE",
77
+ sortDirection: (sorting.order || "ASC").toUpperCase(),
78
+ order: getSortOrder(sorting, category, body),
79
+ };
80
+ let obj;
81
+ if (categoryId) {
82
+ obj = {
83
+ questionid: category.id,
84
+ linkid: category.linkid,
85
+ maxDataPoints,
86
+ property: category.property,
87
+ qrveyid: category.qrveyid || body.qrveyid,
88
+ type: category.type || body.type,
89
+ sortOption: (0, columns_1.isNumericalColumn)(category) &&
90
+ (0, general_1._get)(category, "scaleType.value") === "CONTINUOUS"
91
+ ? undefined
92
+ : pSortOption,
93
+ };
94
+ setDateGroup(category, body, obj);
95
+ }
96
+ return obj;
97
+ }
98
+ exports.getCategoryBody = getCategoryBody;
99
+ function getComboBody(layer, body, filters, newModel = false) {
100
+ const obj = {};
101
+ try {
102
+ const category = getCategoryBody((0, general_1._get)(body, "layerList[0]"), body);
103
+ const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => (0, general_1._get)(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
104
+ if (newModel) {
105
+ obj.dimensions = [];
106
+ if (pSmallMultiple)
107
+ obj.dimensions.push(pSmallMultiple);
108
+ obj.dimensions.push(category);
109
+ }
110
+ else {
111
+ obj.category = category;
112
+ }
113
+ obj.summaries = getSummariesBody(layer, body);
114
+ obj.aggFilters = getAggFiltersResults(filters, obj.summaries);
115
+ }
116
+ catch (error) {
117
+ console.error(error);
118
+ }
119
+ return obj;
120
+ }
121
+ exports.getComboBody = getComboBody;
122
+ function getSmallMultipleBody(layer, body) {
123
+ if (!layer)
124
+ return null;
125
+ const category = (0, general_1._get)(layer, "smallMultiplesColumn");
126
+ const maxDataPoints = !(0, endpointDataValidators_1.isColumnDate)(category)
127
+ ? (0, general_1._get)(layer, "visualization.maxMultiplePanels", undefined)
128
+ : undefined;
129
+ if (category && category.bucketId)
130
+ category.id = category.bucketId;
131
+ const categoryId = category ? category.id : null;
132
+ let obj;
133
+ if (categoryId) {
134
+ obj = {
135
+ questionid: category.id,
136
+ linkid: category.linkid,
137
+ maxDataPoints: maxDataPoints,
138
+ property: category.property,
139
+ qrveyid: category.qrveyid || body.qrveyid,
140
+ type: category.type || body.type,
141
+ };
142
+ if ((0, columns_1.isNumericalColumn)(category))
143
+ obj.numberAsRange = true;
144
+ setDateGroup(category, category, obj);
145
+ }
146
+ return obj;
147
+ }
148
+ exports.getSmallMultipleBody = getSmallMultipleBody;
149
+ function getAggFiltersResults(logics = [], summaries = []) {
150
+ function concatAggFilters(aggFilters, operator = filters_1.FILTER_OPERATOR.AND) {
151
+ const expressions = aggFilters.filter(Boolean);
152
+ if (!expressions.length)
153
+ return undefined;
154
+ else if (expressions.length === 1)
155
+ return expressions[0];
156
+ return {
157
+ operator,
158
+ expressions: aggFilters.filter(Boolean),
159
+ };
160
+ }
161
+ function getExpressionsInLogic(logicsData = []) {
162
+ return logicsData.reduce((expressions, logic) => {
163
+ logic.filters.forEach((filter) => {
164
+ expressions = expressions.concat(filter.expressions[0].expressions);
165
+ });
166
+ return expressions;
167
+ }, []);
168
+ }
169
+ function getAggregateFilters(logicsData = []) {
170
+ logicsData = (0, general_1.cloneDeep)(logicsData);
171
+ const aggregateLogics = logicsData.reduce((newLogics, logic) => {
172
+ if (!logic)
173
+ return newLogics;
174
+ // if ([FILTER_SCOPE.DEFAULT, FILTER_SCOPE.CHART].includes(logic.scope)) {
175
+ logic.filters.forEach((filter, index) => {
176
+ const expressions = (0, general_1._get)(filter, "expressions[0].expressions");
177
+ if (!(0, general_1.isEmpty)(expressions)) {
178
+ const aggregateFilters = filter.expressions[0].expressions.filter((expression) => !(0, general_1.isEmpty)(expression.uiExtras.column.aggregate));
179
+ logic.filters[index].expressions[0].expressions = aggregateFilters;
180
+ if (!filter.expressions[0].expressions.length)
181
+ logic.filters[index] = undefined;
182
+ }
183
+ });
184
+ logic.filters = logic.filters.filter((filter) => filter);
185
+ if (logic.filters.length)
186
+ newLogics.push(logic);
187
+ //}
188
+ return newLogics;
189
+ }, []);
190
+ return aggregateLogics;
191
+ }
192
+ const aggregateFilters = getAggregateFilters(logics);
193
+ const aggFilters = aggregateFilters
194
+ .map((aggFilter) => {
195
+ const expressions = getExpressionsInLogic([aggFilter]);
196
+ return (expressions &&
197
+ expressions.length && {
198
+ operator: filters_1.FILTER_OPERATOR.OR,
199
+ expressions: expressions
200
+ .map((expression) => {
201
+ const summaryIndex = summaries.findIndex((summary) => expression.questionid === summary.questionid &&
202
+ expression.qrveyid === summary.qrveyid &&
203
+ expression.linkid === summary.linkid &&
204
+ (0, general_1._get)(expression.uiExtras.column, "aggregate") ===
205
+ summary.aggregate);
206
+ if (summaryIndex > -1 ||
207
+ expression.questionType === columns_1.COLUMN.AGGREGATED_FORMULA) {
208
+ return {
209
+ enabled: expression.enabled,
210
+ summaryIndex,
211
+ validationType: expression.validationType,
212
+ value: expression.value,
213
+ };
214
+ }
215
+ return;
216
+ })
217
+ .filter(Boolean),
218
+ });
219
+ })
220
+ .filter((aggFilter) => aggFilter && aggFilter.expressions && aggFilter.expressions.length);
221
+ return aggFilters && concatAggFilters(aggFilters);
222
+ }
223
+ exports.getAggFiltersResults = getAggFiltersResults;
224
+ function getRefenceBody(layer) {
225
+ let obj;
226
+ try {
227
+ obj = {
228
+ type: "REFERENCE_LINE",
229
+ referenceType: layer.valuetype,
230
+ referenceValue: layer.value,
231
+ valueId: (0, general_1._get)(layer, "axis.id"),
232
+ aggregate: (0, general_1._get)(layer, "aggregate.label"),
233
+ value: {
234
+ questionid: (0, general_1._get)(layer, "axis.id"),
235
+ qrveyid: (0, general_1._get)(layer, "axis.qrveyid"),
236
+ linkid: (0, general_1._get)(layer, "axis.linkid"),
237
+ property: (0, general_1._get)(layer, "axis.property"),
238
+ type: (0, general_1._get)(layer, "axis.type", (0, general_1._get)(layer, "axis.label")),
239
+ },
240
+ };
241
+ }
242
+ catch (e) {
243
+ console.error(e);
244
+ }
245
+ return obj;
246
+ }
247
+ exports.getRefenceBody = getRefenceBody;
248
+ function getTrendBody(layer) {
249
+ let obj;
250
+ try {
251
+ obj = {
252
+ type: "TREND_LINE",
253
+ trendType: layer.trendtype.label,
254
+ };
255
+ }
256
+ catch (e) {
257
+ console.error(e);
258
+ }
259
+ return obj;
260
+ }
261
+ exports.getTrendBody = getTrendBody;
262
+ function getRefenceBodyU(layer, body) {
263
+ let obj;
264
+ const layerType = layer.valuetype === "Fixed";
265
+ const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => (0, general_1._get)(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
266
+ if (!layerType) {
267
+ obj = {
268
+ summaries: [
269
+ {
270
+ aggregate: (0, general_1._get)(layer, "aggregate.label"),
271
+ linkid: (0, general_1._get)(layer, "axis.linkid"),
272
+ property: (0, general_1._get)(layer, "axis.property"),
273
+ qrveyid: (0, general_1._get)(layer, "axis.qrveyid") || body.qrveyid,
274
+ questionid: (0, general_1._get)(layer, "axis.id"),
275
+ type: (0, general_1._get)(layer, "axis.type", (0, general_1._get)(layer, "axis.label")),
276
+ },
277
+ ],
278
+ };
279
+ if (pSmallMultiple)
280
+ obj.dimensions = [pSmallMultiple];
281
+ }
282
+ else {
283
+ obj = { type: "REFERENCE_LINE" };
284
+ }
285
+ return obj;
286
+ }
287
+ exports.getRefenceBodyU = getRefenceBodyU;
288
+ function getLayerBody(layer, dateGroup, qrveyid) {
289
+ let obj;
290
+ try {
291
+ if ((0, general_1._get)(layer, "mapType.label") == "DOT")
292
+ obj = {};
293
+ // eslint-disable-next-line no-extra-boolean-cast
294
+ else if (!!~["BOXWHISKER_CHART", "WORD_CLOUD"].indexOf(layer.type)) {
295
+ obj = {
296
+ valueId: (0, general_1._get)(layer, "value.id"),
297
+ aggregate: (0, general_1._get)(layer, "aggregate.label"),
298
+ };
299
+ }
300
+ else {
301
+ obj = {
302
+ valueId: layer.value.id,
303
+ aggregate: layer.aggregate.label,
304
+ };
305
+ }
306
+ obj.type =
307
+ layer.type || (0, general_1._get)(layer, "layer.label", (0, general_1._get)(layer, "combopt.label"));
308
+ obj.property = layer.property;
309
+ if (layer.value)
310
+ obj.value = {
311
+ questionid: layer.value.id,
312
+ type: layer.value.type,
313
+ qrveyid: layer.value.qrveyid,
314
+ linkid: layer.value.linkid,
315
+ property: layer.value.property,
316
+ };
317
+ if (layer.mapType)
318
+ obj.mapType = layer.mapType.label;
319
+ if (layer.multiserie && layer.multiserie.serie) {
320
+ if (layer.multiserie.serie.type === "BUCKET") {
321
+ obj.multiValueId = layer.multiserie.serie.bucketId; //required
322
+ obj.multiValueType = "BUCKET";
323
+ }
324
+ else {
325
+ obj.multiValueId = layer.multiserie.serie.id; //required
326
+ obj.multiValueType = undefined;
327
+ }
328
+ obj.isMulti = true;
329
+ obj.multiValueAxis = {
330
+ questionid: layer.multiserie.serie.id,
331
+ groupType: (0, general_1._get)(layer, "multiserie.type"),
332
+ questionType: (0, general_1._get)(layer, "multiserie.serie.type"),
333
+ type: (0, general_1._get)(layer, "multiserie.serie.type"),
334
+ groupValue: (0, general_1._get)(layer, "multiserie.dateGroup.label"),
335
+ property: (0, general_1._get)(layer, "multiserie.serie.property"),
336
+ qrveyid: (0, general_1._get)(layer, "multiserie.serie.qrveyid"),
337
+ linkid: (0, general_1._get)(layer, "multiserie.serie.linkid"),
338
+ };
339
+ if ((0, general_1._get)(layer, "multiserie.maxDataPoints", false))
340
+ obj.multiValueAxis.maxDataPoints = (0, general_1._get)(layer, "multiserie.maxNumDataPoints", 50);
341
+ }
342
+ if (dateGroup && dateGroup.label) {
343
+ obj.groupType = "DATE";
344
+ obj.groupValue = dateGroup.label;
345
+ }
346
+ if (layer.pivot) {
347
+ obj.pivot = {};
348
+ obj.pivot.qrveyid = (0, general_1._get)(layer, "pivot.qrveyid", qrveyid);
349
+ obj.pivot.linkid = (0, general_1._get)(layer, "pivot.linkid");
350
+ obj.pivot.groupType = (0, general_1._get)(layer, "pivot.type");
351
+ obj.pivot.type = (0, general_1._get)(layer, "pivot.type");
352
+ const labelBucketId = (0, general_1._get)(layer, "pivot.bucketId", null);
353
+ if (labelBucketId !== null) {
354
+ obj.pivot.labelBucketId = labelBucketId;
355
+ }
356
+ else {
357
+ obj.pivot.questionid = (0, general_1._get)(layer, "pivot.id");
358
+ }
359
+ obj.pivot.groupValue = (0, general_1._get)(layer, "pivot.dateGroup.label");
360
+ obj.pivot.property = (0, general_1._get)(layer, "pivot.property");
361
+ }
362
+ }
363
+ catch (error) {
364
+ console.error(error);
365
+ }
366
+ return obj;
367
+ }
368
+ exports.getLayerBody = getLayerBody;
369
+ function getSortOrder(sorting = {}, category = {}, body = {}) {
370
+ var _a;
371
+ const order = (sorting.order || "ASC").toUpperCase();
372
+ const column = sorting.column || {};
373
+ const aggregate = (_a = body.globalSettings) === null || _a === void 0 ? void 0 : _a.sortAggregation;
374
+ return column.isHidden
375
+ ? [
376
+ {
377
+ hidden: true,
378
+ type: column.type,
379
+ sortDirection: order,
380
+ questionid: column.id,
381
+ qrveyid: column.qrveyid,
382
+ aggregate: aggregate === null || aggregate === void 0 ? void 0 : aggregate.label,
383
+ property: column.property || category.property,
384
+ },
385
+ ]
386
+ : [
387
+ {
388
+ summaryIndex: 0,
389
+ sortDirection: order,
390
+ },
391
+ ];
392
+ }
393
+ function setDateGroup(column, body, obj) {
394
+ if ((0, endpointDataValidators_1.isColumnDate)(column) && !(0, general_1.isEmpty)((0, general_1._get)(body, "dateGroup.label"))) {
395
+ obj["groupType"] = columns_1.COLUMN.DATE;
396
+ obj["groupValue"] = body.dateGroup.label;
397
+ if ((0, general_1._get)(body, "dateGroup.datePart", false)) {
398
+ obj["maxDataPoints"] = obj["maxDataPoints"] || 60;
399
+ }
400
+ }
401
+ }
402
+ exports.setDateGroup = setDateGroup;
403
+ function getSummariesBody(layer, body) {
404
+ let value = (0, general_1._get)(layer, "value");
405
+ let aggregate = (0, general_1._get)(layer, "aggregate");
406
+ if (layer.type === "WORD_CLOUD" && !value)
407
+ value = (0, general_1._get)(layer, "category");
408
+ if (layer.type === "WORD_CLOUD" && !aggregate)
409
+ aggregate = { label: "COUNT", text: "Count" };
410
+ let obj;
411
+ if (layer.type === "MINMAX_CHART" && value) {
412
+ const min = aggregateGenerator("MIN", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
413
+ const max = aggregateGenerator("MAX", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
414
+ obj = [min, max];
415
+ if (body.globalSettings.average)
416
+ obj.push(aggregateGenerator("AVG", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type));
417
+ }
418
+ else if (value) {
419
+ obj = [
420
+ {
421
+ aggregate: aggregate && aggregate.label,
422
+ linkid: value.linkid,
423
+ property: value.property,
424
+ qrveyid: value.qrveyid || body.qrveyid,
425
+ questionid: value.id,
426
+ type: value.type,
427
+ },
428
+ ];
429
+ if (value.calculation)
430
+ obj[0].calculations = value.calculation;
431
+ }
432
+ return obj;
433
+ }
434
+ exports.getSummariesBody = getSummariesBody;
435
+ function aggregateGenerator(aggregate, linkid, property, qrveyid, questionid, type) {
436
+ return {
437
+ type,
438
+ linkid,
439
+ qrveyid,
440
+ property,
441
+ questionid,
442
+ aggregate: aggregate !== null && aggregate !== void 0 ? aggregate : "SUM",
443
+ };
444
+ }
@@ -0,0 +1,4 @@
1
+ export declare function isNotValid(mainLayer: any): boolean;
2
+ export declare function validChartTypeWithEndPoint(chartType: any): boolean;
3
+ export declare function hasMinorVersion(version: any, current: any): boolean;
4
+ export declare function isColumnDate(column: any): boolean;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isColumnDate = exports.hasMinorVersion = exports.validChartTypeWithEndPoint = exports.isNotValid = void 0;
4
+ const columns_1 = require("../../columns");
5
+ const constants_1 = require("../../constants");
6
+ function isNotValid(mainLayer) {
7
+ if (!mainLayer)
8
+ return;
9
+ const chartType = mainLayer.type;
10
+ switch (chartType) {
11
+ case constants_1.CHART_TYPE.GEO_CHART:
12
+ if (mainLayer.mapType && mainLayer.mapType.label === "DOT")
13
+ return !mainLayer.category;
14
+ break;
15
+ case constants_1.CHART_TYPE.WORD_CLOUD:
16
+ return !mainLayer.category;
17
+ case constants_1.CHART_TYPE.BOXWHISKER_CHART:
18
+ return !mainLayer.value;
19
+ case constants_1.CHART_TYPE.MINMAX_CHART:
20
+ return !mainLayer.value;
21
+ case constants_1.CHART_TYPE.TABLE_CHART:
22
+ case constants_1.CHART_TYPE.CROSSTAB_CHART:
23
+ case constants_1.CHART_TYPE.EXPANDABLE_TABLE_CHART:
24
+ return true;
25
+ }
26
+ return (!mainLayer.category ||
27
+ !mainLayer.value ||
28
+ (chartType !== "SYMBOL_CHART" && !mainLayer.aggregate));
29
+ }
30
+ exports.isNotValid = isNotValid;
31
+ function validChartTypeWithEndPoint(chartType) {
32
+ return [
33
+ constants_1.CHART_TYPE.BAR_CHART,
34
+ constants_1.CHART_TYPE.LINE_CHART,
35
+ constants_1.CHART_TYPE.MINMAX_CHART,
36
+ constants_1.CHART_TYPE.SYMBOL_CHART,
37
+ constants_1.CHART_TYPE.PIE_CHART,
38
+ constants_1.CHART_TYPE.HEATMAP_CHART,
39
+ constants_1.CHART_TYPE.WORD_CLOUD,
40
+ constants_1.CHART_TYPE.FUNNEL_CHART,
41
+ ].includes(chartType);
42
+ }
43
+ exports.validChartTypeWithEndPoint = validChartTypeWithEndPoint;
44
+ function hasMinorVersion(version, current) {
45
+ const splitVersion = (v) => v.split(".").map((t) => parseInt(t));
46
+ const currentVersion = splitVersion(current);
47
+ const chartVersion = splitVersion(version);
48
+ if (chartVersion[0] < currentVersion[0])
49
+ return true;
50
+ else if (chartVersion[1] < currentVersion[1])
51
+ return true;
52
+ return false;
53
+ }
54
+ exports.hasMinorVersion = hasMinorVersion;
55
+ function isColumnDate(column) {
56
+ if (column == null)
57
+ return;
58
+ return (column.type === columns_1.COLUMN.DATE ||
59
+ (column.type === columns_1.COLUMN.FORMULA && column.formulaType === "date"));
60
+ }
61
+ exports.isColumnDate = isColumnDate;
@@ -0,0 +1,3 @@
1
+ export * from "./endpointDataValidators";
2
+ export * from "./endpointDataGet";
3
+ export * from "./endpointData";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./endpointDataValidators"), exports);
18
+ __exportStar(require("./endpointDataGet"), exports);
19
+ __exportStar(require("./endpointData"), exports);
@@ -1,2 +1,3 @@
1
1
  export * from "./constants/index";
2
2
  export * from "./interfaces/index";
3
+ export * from "./adapters/index";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants/index"), exports);
18
18
  __exportStar(require("./interfaces/index"), exports);
19
+ __exportStar(require("./adapters/index"), exports);
@@ -10,6 +10,7 @@ const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
10
10
  const columnTypeByChart_1 = require("./columnTypeByChart");
11
11
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
12
12
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
13
+ const DURATION_PARTS_LIST_1 = require("../constants/DURATION_PARTS_LIST");
13
14
  /**
14
15
  * It returns the format of a column based on the column type, the chart type, and the chart settings
15
16
  * @param {IChartColumn} column - IChartColumn
@@ -60,17 +61,25 @@ const defineTableChartFormat = (column, settings) => {
60
61
  case COLUMN_1.COLUMN.NUMERIC:
61
62
  case COLUMN_1.COLUMN.RATING:
62
63
  case COLUMN_1.COLUMN.SLIDEBAR: {
63
- if (selectedFormat)
64
- return selectedFormat;
65
- if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF)
66
- return defaultPercentage;
67
- if (hasDefaultFormat) {
68
- if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
69
- (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)
70
- return defaultNumeric;
71
- return defaultFormat || defaultNumeric;
64
+ let output;
65
+ if (selectedFormat && selectedFormat.format !== "Default") {
66
+ output = selectedFormat;
72
67
  }
73
- return;
68
+ else if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF) {
69
+ output = defaultPercentage;
70
+ }
71
+ else if (isGroupedTable &&
72
+ ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
73
+ (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)) {
74
+ output = defaultNumeric;
75
+ }
76
+ else {
77
+ output = defaultFormat || defaultNumeric;
78
+ }
79
+ if (DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
80
+ output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
81
+ }
82
+ return output;
74
83
  }
75
84
  }
76
85
  };
@@ -1,5 +1,6 @@
1
1
  export declare enum CHART_TYPE {
2
2
  BAR_CHART = "BAR_CHART",
3
+ FUNNEL_CHART = "FUNNEL_CHART",
3
4
  BAR_CHART_MS = "BAR_CHART_MS",
4
5
  EXPANDABLE_TABLE_CHART = "EXPANDABLE_TABLE_CHART",
5
6
  SYMBOL_CHART = "SYMBOL_CHART",
@@ -4,6 +4,7 @@ exports.CHART_DIMENSION = exports.CHART_TYPE = void 0;
4
4
  var CHART_TYPE;
5
5
  (function (CHART_TYPE) {
6
6
  CHART_TYPE["BAR_CHART"] = "BAR_CHART";
7
+ CHART_TYPE["FUNNEL_CHART"] = "FUNNEL_CHART";
7
8
  CHART_TYPE["BAR_CHART_MS"] = "BAR_CHART_MS";
8
9
  CHART_TYPE["EXPANDABLE_TABLE_CHART"] = "EXPANDABLE_TABLE_CHART";
9
10
  CHART_TYPE["SYMBOL_CHART"] = "SYMBOL_CHART";
@@ -8,4 +8,5 @@ exports.DATETIME_COLUMN_FORMAT = [
8
8
  "MM/DD/YYYY HH24:MI:SS",
9
9
  "DD/MM/YYYY HH24:MI:SS",
10
10
  "YYYY-MM-DD HH24:MI:SS",
11
+ "YYYY-MM-DD HH:mm:ss",
11
12
  ];
@@ -12,7 +12,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
12
12
  * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
13
13
  */
14
14
  function getTokensFromFilters(filters, options) {
15
- var _a, _b;
15
+ var _a, _b, _c;
16
16
  const tokens = [];
17
17
  const i18nService = options.i18nService;
18
18
  const settings = {
@@ -48,16 +48,21 @@ function getTokensFromFilters(filters, options) {
48
48
  });
49
49
  }
50
50
  for (const [index, filter] of Object.entries(database.filters)) {
51
- if (!(filter === null || filter === void 0 ? void 0 : filter.enabled))
51
+ if (!(filter === null || filter === void 0 ? void 0 : filter.enabled)) {
52
+ if (((_a = tokens[tokens.length - 1]) === null || _a === void 0 ? void 0 : _a.type) ===
53
+ FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
54
+ tokens.pop();
55
+ }
52
56
  continue;
57
+ }
53
58
  const values = (0, getUIValues_1.getUIValues)(filter, settings);
54
59
  if (!thereIsFiltersWithValues)
55
60
  thereIsFiltersWithValues = true;
56
61
  let columnLabel = filter.column.label;
57
- if ((_a = filter === null || filter === void 0 ? void 0 : filter.column) === null || _a === void 0 ? void 0 : _a.aggregate) {
62
+ if ((_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate) {
58
63
  columnLabel +=
59
64
  " (" +
60
- i18nService.translate(`common.aggregate_labels.${(_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate.toLowerCase()}`) +
65
+ i18nService.translate(`common.aggregate_labels.${(_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate.toLowerCase()}`) +
61
66
  ")";
62
67
  }
63
68
  tokens.push({
@@ -11,6 +11,7 @@ import { II18nBucketBuilder } from "./bucket_builder/II18nBucketBuilder";
11
11
  import { II18nCrossTabs } from "./cross_tabs";
12
12
  import { II18nChartBuilder } from ".";
13
13
  import { II18nStyleThemes } from "./style_themes/II18nStyleThemes";
14
+ import { II18nTabularView } from './tabular_view/II18nTabularView';
14
15
  export interface II18nResource {
15
16
  bucket_builder?: II18nBucketBuilder;
16
17
  chart_builder?: II18nChartBuilder;
@@ -25,4 +26,5 @@ export interface II18nResource {
25
26
  panel?: II18nPanel;
26
27
  style_themes?: II18nStyleThemes;
27
28
  table_charts?: II18nTableCharts;
29
+ tabular_view?: II18nTabularView;
28
30
  }
@@ -14,4 +14,5 @@ export interface II18nChartBuilderFormatValues {
14
14
  custom: string;
15
15
  date_format: string;
16
16
  value_format: string;
17
+ duration: string;
17
18
  }