@splunk/visualizations 26.4.1 → 27.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 (153) hide show
  1. package/Area.config.js +1399 -1590
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3750 -4822
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1423 -1566
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +3856 -4884
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +1009 -1200
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2768 -4491
  12. package/Bubble.js.map +7 -1
  13. package/ChoroplethSvg.config.js +282 -582
  14. package/ChoroplethSvg.config.js.map +7 -1
  15. package/ChoroplethSvg.js +2032 -3808
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1390 -1534
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +3849 -4906
  20. package/Column.js.map +7 -1
  21. package/Ellipse.config.js +443 -774
  22. package/Ellipse.config.js.map +7 -1
  23. package/Ellipse.js +1667 -3327
  24. package/Ellipse.js.map +7 -1
  25. package/Events.config.js +207 -492
  26. package/Events.config.js.map +7 -1
  27. package/Events.js +2643 -4647
  28. package/Events.js.map +7 -1
  29. package/FillerGauge.config.js +420 -775
  30. package/FillerGauge.config.js.map +7 -1
  31. package/FillerGauge.js +2164 -4575
  32. package/FillerGauge.js.map +7 -1
  33. package/Image.config.js +144 -411
  34. package/Image.config.js.map +7 -1
  35. package/Image.js +1423 -3046
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1421 -1616
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +3790 -4901
  40. package/Line.js.map +7 -1
  41. package/LinkGraph.config.js +390 -632
  42. package/LinkGraph.config.js.map +7 -1
  43. package/LinkGraph.js +5272 -6185
  44. package/LinkGraph.js.map +7 -1
  45. package/MIGRATION.md +6 -0
  46. package/Map.config.js +501 -801
  47. package/Map.config.js.map +7 -1
  48. package/Map.js +3382 -5659
  49. package/Map.js.map +7 -1
  50. package/Markdown.config.js +232 -528
  51. package/Markdown.config.js.map +7 -1
  52. package/Markdown.js +1671 -3212
  53. package/Markdown.js.map +7 -1
  54. package/MarkerGauge.config.js +308 -613
  55. package/MarkerGauge.config.js.map +7 -1
  56. package/MarkerGauge.js +2215 -4531
  57. package/MarkerGauge.js.map +7 -1
  58. package/ParallelCoordinates.config.js +282 -581
  59. package/ParallelCoordinates.config.js.map +7 -1
  60. package/ParallelCoordinates.js +2057 -4718
  61. package/ParallelCoordinates.js.map +7 -1
  62. package/Pie.config.js +278 -547
  63. package/Pie.config.js.map +7 -1
  64. package/Pie.js +2107 -3984
  65. package/Pie.js.map +7 -1
  66. package/Punchcard.config.js +291 -578
  67. package/Punchcard.config.js.map +7 -1
  68. package/Punchcard.js +2734 -5037
  69. package/Punchcard.js.map +7 -1
  70. package/Rectangle.config.js +455 -770
  71. package/Rectangle.config.js.map +7 -1
  72. package/Rectangle.js +1664 -3258
  73. package/Rectangle.js.map +7 -1
  74. package/Sankey.config.js +291 -626
  75. package/Sankey.config.js.map +7 -1
  76. package/Sankey.js +2766 -4908
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +988 -1180
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2801 -4506
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +794 -1250
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4185 -7327
  85. package/SingleValue.js.map +7 -1
  86. package/SingleValueBasic.js +382 -1527
  87. package/SingleValueBasic.js.map +7 -1
  88. package/SingleValueIcon.config.js +757 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3427 -6293
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +686 -1121
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3923 -6994
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/TRELLIS.md +16 -15
  99. package/Table.config.js +565 -879
  100. package/Table.config.js.map +7 -1
  101. package/Table.js +3260 -5334
  102. package/Table.js.map +7 -1
  103. package/common/Charting.js +617 -1498
  104. package/common/Charting.js.map +7 -1
  105. package/common/ChartingApi.js +46 -170
  106. package/common/ChartingApi.js.map +7 -1
  107. package/common/DocExampleWithVizSandbox.js +270 -473
  108. package/common/DocExampleWithVizSandbox.js.map +7 -1
  109. package/common/EventsDoc.js +172 -464
  110. package/common/EventsDoc.js.map +7 -1
  111. package/common/GaugeMajorTicks.js +249 -347
  112. package/common/GaugeMajorTicks.js.map +7 -1
  113. package/common/GaugeValueMarker.js +201 -311
  114. package/common/GaugeValueMarker.js.map +7 -1
  115. package/common/OptionsDoc.js +351 -911
  116. package/common/OptionsDoc.js.map +7 -1
  117. package/common/OverviewDoc.js +435 -769
  118. package/common/OverviewDoc.js.map +7 -1
  119. package/common/SplunkVisualization.js +116 -259
  120. package/common/SplunkVisualization.js.map +7 -1
  121. package/common/SplunkVisualizationApi.js +40 -156
  122. package/common/SplunkVisualizationApi.js.map +7 -1
  123. package/common/ThemesDoc.js +271 -420
  124. package/common/ThemesDoc.js.map +7 -1
  125. package/common/chartingUtils.js +140 -312
  126. package/common/chartingUtils.js.map +7 -1
  127. package/common/docUtils.js +148 -266
  128. package/common/docUtils.js.map +7 -1
  129. package/common/gaugeUtils.js +280 -808
  130. package/common/gaugeUtils.js.map +7 -1
  131. package/common/shapeUtils.js +106 -211
  132. package/common/shapeUtils.js.map +7 -1
  133. package/common/utils/configUtils.js +126 -252
  134. package/common/utils/configUtils.js.map +7 -1
  135. package/common/utils/dataUtils.js +217 -812
  136. package/common/utils/dataUtils.js.map +7 -1
  137. package/common/utils/featureFlagUtils.js +53 -133
  138. package/common/utils/featureFlagUtils.js.map +7 -1
  139. package/common/utils/hocUtils.js +32 -122
  140. package/common/utils/hocUtils.js.map +7 -1
  141. package/common/utils/mapUtils.js +502 -1337
  142. package/common/utils/mapUtils.js.map +7 -1
  143. package/common/utils/singleValueUtils.js +466 -1013
  144. package/common/utils/singleValueUtils.js.map +7 -1
  145. package/common/utils/testHelper.js +92 -146
  146. package/common/utils/testHelper.js.map +7 -1
  147. package/common/utils/trellisUtils.js +277 -489
  148. package/common/utils/trellisUtils.js.map +7 -1
  149. package/common/utils/urlUtils.js +28 -112
  150. package/common/utils/urlUtils.js.map +7 -1
  151. package/common/withDashboardViz.js +1191 -2431
  152. package/common/withDashboardViz.js.map +7 -1
  153. package/package.json +53 -45
@@ -1,471 +1,264 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 58);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ({
94
-
95
- /***/ 0:
96
- /***/ (function(module, exports) {
97
-
98
- module.exports = require("lodash");
99
-
100
- /***/ }),
101
-
102
- /***/ 2:
103
- /***/ (function(module, exports) {
104
-
105
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
106
-
107
- /***/ }),
108
-
109
- /***/ 58:
110
- /***/ (function(module, exports, __webpack_require__) {
111
-
112
- "use strict";
113
-
114
-
115
- var _toConsumableArray = __webpack_require__(2);
116
-
117
- Object.defineProperty(exports, "__esModule", {
118
- value: true
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/common/utils/trellisUtils.ts
34
+ var trellisUtils_exports2 = {};
35
+ __export(trellisUtils_exports2, {
36
+ AGGREGATIONS: () => AGGREGATIONS,
37
+ dataSourcesSplitByAggregationsStats: () => dataSourcesSplitByAggregationsStats,
38
+ dataSourcesSplitByAggregationsTimechartAndChart: () => dataSourcesSplitByAggregationsTimechartAndChart,
39
+ dataSourcesSplitByAggregationsUnknown: () => dataSourcesSplitByAggregationsUnknown,
40
+ dataSourcesSplitByModeChart: () => dataSourcesSplitByModeChart,
41
+ dataSourcesSplitByModeStatsorUnknown: () => dataSourcesSplitByModeStatsorUnknown,
42
+ dataSourcesSplitByModeTimechart: () => dataSourcesSplitByModeTimechart,
43
+ determineMinMax: () => determineMinMax,
44
+ getTrellisDataSourcesBySplitMode: () => getTrellisDataSourcesBySplitMode,
45
+ turnOffLegendDisplayWhenTrellisIsOn: () => turnOffLegendDisplayWhenTrellisIsOn
119
46
  });
120
- exports.getTrellisDataSourcesBySplitMode = exports.dataSourcesSplitByModeStatsorUnknown = exports.dataSourcesSplitByModeChart = exports.dataSourcesSplitByModeTimechart = exports.dataSourcesSplitByAggregationsStats = exports.dataSourcesSplitByAggregationsTimechartAndChart = exports.dataSourcesSplitByAggregationsUnknown = exports.AGGREGATIONS = void 0;
121
-
122
- var lodash_1 = __webpack_require__(0);
47
+ module.exports = __toCommonJS(trellisUtils_exports2);
123
48
 
124
- var trellisUtils_1 = __webpack_require__(59);
125
-
126
- exports.AGGREGATIONS = 'aggregations';
127
- /**
128
- * There can be certain SPL cmds that can produce dataSource without a specific field meta info (like group_by_rank, split_by_field etc),
129
- * to categorize it,
130
- * Example1:- `index = "_internal" | chart count`
131
- * Example2:- `index=_internal | chart avg(count), max(count)`
132
- * Example3:- `index = "_internal" | stats count`
133
- * Example4:- `index=_internal | stats avg(count), max(count)`
134
- */
49
+ // esm-externals:lodash
50
+ var lodash_exports = {};
51
+ __export(lodash_exports, {
52
+ default: () => lodash_default
53
+ });
54
+ var defaultImport = __toESM(require("lodash"));
55
+ __reExport(lodash_exports, require("lodash"));
56
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
57
+
58
+ // esm-externals:@splunk/visualizations-shared/trellisUtils
59
+ var trellisUtils_exports = {};
60
+ __export(trellisUtils_exports, {
61
+ default: () => trellisUtils_default
62
+ });
63
+ var defaultImport2 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
64
+ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
65
+ var trellisUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
135
66
 
136
- var dataSourcesSplitByAggregationsUnknown = function dataSourcesSplitByAggregationsUnknown(dataSource) {
67
+ // src/common/utils/trellisUtils.ts
68
+ var AGGREGATIONS = "aggregations";
69
+ var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
137
70
  var _a, _b, _c, _d;
138
-
139
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
140
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
141
- var splitDataSources = null;
142
- var errorCode = null;
143
-
71
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
72
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
73
+ let splitDataSources = null;
74
+ let errorCode = null;
144
75
  if (fields && fields.length) {
145
76
  splitDataSources = {};
146
-
147
- for (var i = 0; i < fields.length; i += 1) {
148
- var fieldName = fields[i].name;
149
-
150
- if (!(fieldName === null || fieldName === void 0 ? void 0 : fieldName.startsWith('_'))) {
151
- splitDataSources[fieldName] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
77
+ for (let i = 0; i < fields.length; i += 1) {
78
+ const fieldName = fields[i].name;
79
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
80
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
81
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
82
+ );
152
83
  splitDataSources[fieldName].primary.data.fields = [fields[i]];
153
84
  splitDataSources[fieldName].primary.data.columns = [columns[i]];
154
85
  }
155
86
  }
156
87
  } else {
157
- errorCode = 'INVALID_SPLIT_BY_FIELD';
88
+ errorCode = "INVALID_SPLIT_BY_FIELD";
158
89
  }
159
-
160
- return {
161
- splitDataSources: splitDataSources,
162
- errorCode: errorCode
163
- };
90
+ return { splitDataSources, errorCode };
164
91
  };
165
-
166
- exports.dataSourcesSplitByAggregationsUnknown = dataSourcesSplitByAggregationsUnknown;
167
-
168
- var dataSourcesSplitByAggregationsTimechartAndChart = function dataSourcesSplitByAggregationsTimechartAndChart(dataSource) {
92
+ var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
169
93
  var _a, _b, _c, _d;
170
-
171
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
172
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
173
- var splitDataSources = null;
174
- var splitByFields = [];
175
- var errorCode = null;
176
-
177
- if (typeof fields[0] !== 'string') {
178
- splitByFields = (0, trellisUtils_1.extractDataSourceAggregationKeysChart)(fields);
94
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
95
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
96
+ let splitDataSources = null;
97
+ let splitByFields = [];
98
+ let errorCode = null;
99
+ if (typeof fields[0] !== "string") {
100
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
179
101
  }
180
-
181
102
  if (splitByFields && splitByFields.length > 0) {
182
103
  splitDataSources = {};
183
- splitByFields.forEach(function (splitByField) {
184
- splitDataSources[splitByField] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
104
+ splitByFields.forEach((splitByField) => {
105
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
106
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
107
+ );
185
108
  splitDataSources[splitByField].primary.data.fields = [fields[0]];
186
109
  splitDataSources[splitByField].primary.data.columns = [columns[0]];
187
- fields.forEach(function (field, idx) {
188
- var fieldName = field === null || field === void 0 ? void 0 : field.name;
189
-
190
- if (fieldName !== '_time' && !(fieldName === null || fieldName === void 0 ? void 0 : fieldName.startsWith('_')) && field.data_source === splitByField) {
110
+ fields.forEach((field, idx) => {
111
+ const fieldName = field == null ? void 0 : field.name;
112
+ if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
191
113
  splitDataSources[splitByField].primary.data.fields.push(field);
192
114
  splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
193
115
  }
194
116
  });
195
117
  });
196
118
  } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
197
- // handle where data_source doesnot exist in fields
198
- // example1 :- index=_internal | timechart count
199
- // example2 :- index=_internal | timechart max(count) avg(count)
200
119
  splitDataSources = {};
201
-
202
- for (var i = 1; i < fields.length; i += 1) {
203
- var fieldName = fields[i].name;
204
-
205
- if (!(fieldName === null || fieldName === void 0 ? void 0 : fieldName.startsWith('_'))) {
206
- splitDataSources[fieldName] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
120
+ for (let i = 1; i < fields.length; i += 1) {
121
+ const fieldName = fields[i].name;
122
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
123
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
124
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
125
+ );
207
126
  splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
208
127
  splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
209
128
  }
210
129
  }
211
130
  } else {
212
- errorCode = 'INVALID_SPLIT_BY_FIELD';
131
+ errorCode = "INVALID_SPLIT_BY_FIELD";
213
132
  }
214
-
215
- return {
216
- splitDataSources: splitDataSources,
217
- errorCode: errorCode
218
- };
133
+ return { splitDataSources, errorCode };
219
134
  };
220
-
221
- exports.dataSourcesSplitByAggregationsTimechartAndChart = dataSourcesSplitByAggregationsTimechartAndChart;
222
-
223
- var dataSourcesSplitByAggregationsStats = function dataSourcesSplitByAggregationsStats(dataSource) {
135
+ var dataSourcesSplitByAggregationsStats = (dataSource) => {
224
136
  var _a, _b, _c, _d;
225
-
226
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
227
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
228
- var splitDataSources = null;
229
- var splitByFields = [];
230
- var errorCode = null;
231
-
232
- if (typeof fields[0] !== 'string') {
233
- splitByFields = (0, trellisUtils_1.extractDataSourceAggregationKeysStats)(fields);
137
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
138
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
139
+ let splitDataSources = null;
140
+ let splitByFields = [];
141
+ let errorCode = null;
142
+ if (typeof fields[0] !== "string") {
143
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
234
144
  }
235
-
236
145
  if (splitByFields && splitByFields.length > 0) {
237
146
  splitDataSources = {};
238
- splitByFields.forEach(function (splitByField) {
239
- splitDataSources[splitByField] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
147
+ splitByFields.forEach((splitByField) => {
148
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
149
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
150
+ );
240
151
  splitDataSources[splitByField].primary.data.fields = [fields[0]];
241
152
  splitDataSources[splitByField].primary.data.columns = [columns[0]];
242
- var idx = fields.findIndex(function (field) {
243
- return field.name === splitByField;
244
- });
245
-
153
+ const idx = fields.findIndex((field) => field.name === splitByField);
246
154
  if (idx > 0) {
247
155
  splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
248
156
  splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
249
157
  }
250
158
  });
251
159
  } else {
252
- errorCode = 'INVALID_SPLIT_BY_FIELD';
160
+ errorCode = "INVALID_SPLIT_BY_FIELD";
253
161
  }
254
-
255
- return {
256
- splitDataSources: splitDataSources,
257
- errorCode: errorCode
258
- };
162
+ return { splitDataSources, errorCode };
259
163
  };
260
-
261
- exports.dataSourcesSplitByAggregationsStats = dataSourcesSplitByAggregationsStats;
262
-
263
- var dataSourcesSplitByModeTimechart = function dataSourcesSplitByModeTimechart(dataSource, splitBy) {
164
+ var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
264
165
  var _a, _b, _c, _d, _e;
265
-
266
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
267
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
268
- var splitDataSources = null;
269
- var splitByFields = [];
270
- var errorCode = null;
271
-
272
- if (typeof fields[0] !== 'string') {
273
- splitByFields = (0, trellisUtils_1.extractSplitByFieldsChartFields)(fields);
166
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
167
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
168
+ let splitDataSources = null;
169
+ let splitByFields = [];
170
+ let errorCode = null;
171
+ if (typeof fields[0] !== "string") {
172
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
274
173
  }
275
-
276
174
  if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
277
175
  splitDataSources = {};
278
- var dataSourceKeys = (0, trellisUtils_1.extractDataSourceAggregationKeysChart)(fields);
279
- var valueKeys = [];
280
-
281
- for (var i = 1; i < fields.length; i += 1) {
282
- // not including internal fields
283
- if (!((_e = fields[i].name) === null || _e === void 0 ? void 0 : _e.startsWith('_'))) {
176
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
177
+ const valueKeys = [];
178
+ for (let i = 1; i < fields.length; i += 1) {
179
+ if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
284
180
  valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
285
181
  }
286
182
  }
287
-
288
- valueKeys.forEach(function (val) {
289
- splitDataSources[val] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
290
- splitDataSources[val].primary.data.fields = [{
291
- name: fields[0].name
292
- }].concat(_toConsumableArray(dataSourceKeys.map(function (k) {
293
- return {
183
+ valueKeys.forEach((val) => {
184
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
185
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
186
+ );
187
+ splitDataSources[val].primary.data.fields = [
188
+ { name: fields[0].name },
189
+ ...dataSourceKeys.map((k) => ({
294
190
  name: k
295
- };
296
- })));
297
- splitDataSources[val].primary.data.columns = [_toConsumableArray(columns[0])];
298
- dataSourceKeys.forEach(function (dsKey) {
299
- fields.forEach(function (field, idx) {
191
+ }))
192
+ ];
193
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
194
+ dataSourceKeys.forEach((dsKey) => {
195
+ fields.forEach((field, idx) => {
300
196
  if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
301
- splitDataSources[val].primary.data.columns.push(_toConsumableArray(columns[idx]));
197
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
302
198
  }
303
199
  });
304
200
  });
305
201
  });
306
202
  } else {
307
- errorCode = 'INVALID_SPLIT_BY_FIELD';
203
+ errorCode = "INVALID_SPLIT_BY_FIELD";
308
204
  }
309
-
310
- return {
311
- splitDataSources: splitDataSources,
312
- errorCode: errorCode
313
- };
205
+ return { splitDataSources, errorCode };
314
206
  };
315
-
316
- exports.dataSourcesSplitByModeTimechart = dataSourcesSplitByModeTimechart;
317
-
318
- var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSource, splitBy) {
207
+ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
319
208
  var _a, _b, _c, _d;
320
-
321
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
322
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
323
- var splitDataSources = null;
324
- var splitByFields = [];
325
- var errorCode = null;
326
-
327
- if (typeof fields[0] !== 'string') {
328
- splitByFields = (0, trellisUtils_1.extractSplitByFieldsChartFields)(fields);
209
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
210
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
211
+ let splitDataSources = null;
212
+ let splitByFields = [];
213
+ let errorCode = null;
214
+ if (typeof fields[0] !== "string") {
215
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
329
216
  }
330
-
331
217
  if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
332
218
  splitDataSources = {};
333
- var splitByFieldIdx = splitByFields.findIndex(function (f) {
334
- return f === splitBy;
335
- });
336
- var otherSplitBy = splitByFields.filter(function (f) {
337
- return f !== splitBy;
338
- });
339
- var dataSourceKeys = (0, trellisUtils_1.extractDataSourceAggregationKeysChart)(fields);
340
- var nonDataSourceAggregations = [];
341
-
342
- if (!dataSourceKeys.length && fields[0].groupby_rank === '0' && fields.length && !fields[1].groupby_rank) {
343
- /* check for another aggregation scenario where no key 'data_source' will be returned (applies for both chart and stats cmd)
344
- For example :-
345
- index=_internal | chart count by status
346
- index = "_internal" | chart max(count) avg(count) by status
347
- index = "_internal" | stats max(count) avg(count) by status
348
- where field meta info is in this format -
349
- "fields": [
350
- {
351
- "name": "status",
352
- "groupby_rank": "0"
353
- },
354
- {
355
- "name": "max(count)"
356
- },
357
- {
358
- "name": "avg(count)"
359
- }
360
- ]
361
- */
362
- for (var i = 1; i < fields.length; i += 1) {
219
+ const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
220
+ const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
221
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
222
+ const nonDataSourceAggregations = [];
223
+ if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
224
+ for (let i = 1; i < fields.length; i += 1) {
363
225
  nonDataSourceAggregations.push(fields[i].name);
364
226
  }
365
227
  }
366
-
367
228
  if (splitByFieldIdx === 0) {
368
- // if splitBy is the first field, split row wise
369
- var valueKeys = (0, lodash_1.cloneDeep)(columns[0]);
370
- valueKeys.forEach(function (val, idx) {
371
- splitDataSources[val] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
229
+ const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
230
+ valueKeys.forEach((val, idx) => {
231
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
232
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
233
+ );
372
234
  splitDataSources[val].primary.data.fields = [];
373
-
374
235
  if (otherSplitBy.length) {
375
- splitDataSources[val].primary.data.fields = [{
376
- name: otherSplitBy[0]
377
- }]; // there can only be one otherSplitBy for chart cmd
236
+ splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
378
237
  }
379
-
380
238
  if (dataSourceKeys.length) {
381
- (function () {
382
- var columnValues = [[]];
383
- splitDataSources[val].primary.data.fields = [].concat(_toConsumableArray(splitDataSources[val].primary.data.fields), _toConsumableArray(dataSourceKeys.map(function (k) {
384
- return {
385
- name: k
386
- };
387
- })));
388
- dataSourceKeys.forEach(function () {
389
- columnValues.push([]);
239
+ const columnValues = [[]];
240
+ splitDataSources[val].primary.data.fields = [
241
+ ...splitDataSources[val].primary.data.fields,
242
+ ...dataSourceKeys.map((k) => ({
243
+ name: k
244
+ }))
245
+ ];
246
+ dataSourceKeys.forEach(() => {
247
+ columnValues.push([]);
248
+ });
249
+ for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
250
+ columnValues[0].push(
251
+ fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
252
+ );
253
+ dataSourceKeys.forEach((dskey, dsIndx) => {
254
+ const mul = (fields.length - 1) / dataSourceKeys.length;
255
+ columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
390
256
  });
391
- /**
392
- * There can be chart SPL cmd where there are multiple data_source keys in the field meta info.
393
- * For eg - index = "_internal" | chart avg(count) max(count) by status , user) can result in fields and columns as below where "data_source" keys are "avg(count)" and "max(count)"
394
- * 'fields' : [
395
- {
396
- "name": "status",
397
- "groupby_rank": "0"
398
- },
399
- {
400
- "name": "avg(count): userA",
401
- "data_source": "avg(count)",
402
- "splitby_field": "user",
403
- "splitby_value": "userA"
404
- },
405
- {
406
- "name": "avg(count): userB",
407
- "data_source": "avg(count)",
408
- "splitby_field": "user",
409
- "splitby_value": "userB"
410
- },
411
- {
412
- "name": "avg(count): userC",
413
- "data_source": "avg(count)",
414
- "splitby_field": "user",
415
- "splitby_value": "userC"
416
- },
417
- {
418
- "name": "max(count): userA",
419
- "data_source": "max(count)",
420
- "splitby_field": "user",
421
- "splitby_value": "userA"
422
- },
423
- {
424
- "name": "max(count): userB",
425
- "data_source": "max(count)",
426
- "splitby_field": "user",
427
- "splitby_value": "userB"
428
- },
429
- {
430
- "name": "max(count): userC",
431
- "data_source": "max(count)",
432
- "splitby_field": "user",
433
- "splitby_value": "userC"
434
- },
435
- ]
436
- 'columns' : [['200','303','304','400'], ['1','2','3','4'], ['10','20','30','40'], ['100','200','300','400'], ['5','6','7','8'], ['50','60','70','80'],['500','600','700','800']]
437
- In this case when we split row wise, the data_source keys for userA appears in indices [1, 4, ..], the data_source keys for userB appears in indices [2, 5, ..]
438
- The resulting dataSplit for status '200', will have the fields => ['user','avg(count)', 'max(count)'] columns => [['userA', 'userB', 'userC'],['1','10','100'], ['5', '50', '500'] ]
439
- For the example above for..loop below will iterate from i= 1 to 3 (Math.ceil((fields.length - 1) / dataSourceKeys.length)). Exclude i = 0 as first column is the splitBy input.
440
- Since there are 2 data_source keys 'avg(count)' and 'max(count)', dataSourceKeys.forEach loop will collect individual arrays specific to the columnValues[indx] as below.
441
- columnValues[0] = ['userA', 'userB', 'userC']
442
- columnValues[1] = ['1','10','100']
443
- columnValues[2] = ['5', '50', '500']
444
- */
445
-
446
- var _loop = function _loop(_i) {
447
- columnValues[0].push(fields[_i].splitby_value ? fields[_i].splitby_value : fields[_i].name);
448
- dataSourceKeys.forEach(function (dskey, dsIndx) {
449
- var mul = (fields.length - 1) / dataSourceKeys.length; // This line does the index calculation
450
-
451
- columnValues[dsIndx + 1].push(columns[_i + dsIndx * mul][idx]);
452
- });
453
- };
454
-
455
- for (var _i = 1; _i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); _i += 1) {
456
- _loop(_i);
457
- }
458
-
459
- splitDataSources[val].primary.data.columns = columnValues;
460
- })();
257
+ }
258
+ splitDataSources[val].primary.data.columns = columnValues;
461
259
  } else if (nonDataSourceAggregations.length) {
462
- // There can be SPL where data_source field metainfo is not available and needs special handling
463
- // For eg :-
464
- // index=_internal | chart count by status
465
- // index = "_internal" | chart max(count) avg(count) by status
466
- // index = "_internal" | stats max(count) avg(count) by status
467
- var columnValues = [];
468
- fields.forEach(function (aggregationField, fieldIdx) {
260
+ const columnValues = [];
261
+ fields.forEach((aggregationField, fieldIdx) => {
469
262
  if (fieldIdx > 0) {
470
263
  splitDataSources[val].primary.data.fields.push(aggregationField);
471
264
  columnValues.push([columns[fieldIdx][idx]]);
@@ -475,139 +268,134 @@ var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSourc
475
268
  }
476
269
  });
477
270
  } else {
478
- // split column wise
479
- var _valueKeys = [];
480
-
481
- for (var _i2 = 1; _i2 < fields.length; _i2 += 1) {
482
- _valueKeys.push(fields[_i2].splitby_value ? fields[_i2].splitby_value : fields[_i2].name);
271
+ const valueKeys = [];
272
+ for (let i = 1; i < fields.length; i += 1) {
273
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
483
274
  }
484
-
485
- _valueKeys.forEach(function (val) {
486
- splitDataSources[val] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
487
- splitDataSources[val].primary.data.fields = [{
488
- name: otherSplitBy[0]
489
- }].concat(_toConsumableArray(dataSourceKeys.map(function (k) {
490
- return {
275
+ valueKeys.forEach((val) => {
276
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
277
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
278
+ );
279
+ splitDataSources[val].primary.data.fields = [
280
+ { name: otherSplitBy[0] },
281
+ ...dataSourceKeys.map((k) => ({
491
282
  name: k
492
- };
493
- })));
494
- splitDataSources[val].primary.data.columns = [_toConsumableArray(columns[0])];
495
- dataSourceKeys.forEach(function (dsKey) {
496
- fields.forEach(function (field, idx) {
283
+ }))
284
+ ];
285
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
286
+ dataSourceKeys.forEach((dsKey) => {
287
+ fields.forEach((field, idx) => {
497
288
  if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
498
- splitDataSources[val].primary.data.columns.push(_toConsumableArray(columns[idx]));
289
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
499
290
  }
500
291
  });
501
292
  });
502
293
  });
503
294
  }
504
295
  } else {
505
- errorCode = 'INVALID_SPLIT_BY_FIELD';
296
+ errorCode = "INVALID_SPLIT_BY_FIELD";
506
297
  }
507
-
508
- return {
509
- splitDataSources: splitDataSources,
510
- errorCode: errorCode
511
- };
298
+ return { splitDataSources, errorCode };
512
299
  };
513
-
514
- exports.dataSourcesSplitByModeChart = dataSourcesSplitByModeChart;
515
- /**
516
- * This method does datasplitting for 'stats' and generic cmds('makeresults','table' etc - categoried as 'unknown' splitMode).
517
- * The main difference is for 'stats' cmd possible splitBy fields have 'group_by_rank' in field meta info, whereas for 'unknown' cmd it can be any fieldnames
518
- */
519
-
520
- var dataSourcesSplitByModeStatsorUnknown = function dataSourcesSplitByModeStatsorUnknown(dataSource, splitBy, splitMode) {
300
+ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
521
301
  var _a, _b, _c, _d, _e, _f;
522
-
523
- var fields = (_b = (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.fields;
524
- var columns = (_d = (_c = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.columns;
525
- var splitDataSources = null;
526
- var splitByFields = [];
527
- var errorCode = null;
528
-
529
- if (typeof fields[0] !== 'string') {
530
- splitByFields = splitMode !== trellisUtils_1.UNKNOWN ? (0, trellisUtils_1.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_1.extractSplitByFieldsForUnknown)(fields);
302
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
303
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
304
+ let splitDataSources = null;
305
+ let splitByFields = [];
306
+ let errorCode = null;
307
+ if (typeof fields[0] !== "string") {
308
+ splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
531
309
  }
532
-
533
- var splitByIndex = fields === null || fields === void 0 ? void 0 : fields.findIndex(function (field) {
534
- return field === splitBy || field.name === splitBy;
535
- });
536
-
310
+ const splitByIndex = fields == null ? void 0 : fields.findIndex(
311
+ (field) => field === splitBy || field.name === splitBy
312
+ );
537
313
  if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
538
- var splitByColumn = (_f = (_e = dataSource === null || dataSource === void 0 ? void 0 : dataSource.primary) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.columns[splitByIndex];
314
+ const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
539
315
  splitDataSources = {};
540
- splitByColumn.forEach(function (val, idx) {
316
+ splitByColumn.forEach((val, idx) => {
541
317
  if (!splitDataSources[val]) {
542
318
  splitDataSources[val] = [idx];
543
319
  } else {
544
320
  splitDataSources[val].push(idx);
545
321
  }
546
322
  });
547
- var cloneFields = (0, lodash_1.cloneDeep)(fields);
323
+ const cloneFields = (0, lodash_exports.cloneDeep)(fields);
548
324
  cloneFields.splice(splitByIndex, 1);
549
- var valueKeys = Object.keys(splitDataSources);
550
- valueKeys.forEach(function (val) {
551
- var valIndices = (0, lodash_1.cloneDeep)(splitDataSources[val]);
552
- splitDataSources[val] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
325
+ const valueKeys = Object.keys(splitDataSources);
326
+ valueKeys.forEach((val) => {
327
+ const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
328
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
329
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
330
+ );
553
331
  splitDataSources[val].primary.data.fields = cloneFields;
554
332
  splitDataSources[val].primary.data.columns = [];
555
- columns.forEach(function (col, idx) {
333
+ columns.forEach((col, idx) => {
556
334
  if (idx !== splitByIndex) {
557
- var newCol = valIndices.map(function (valIdx) {
558
- return col[valIdx];
559
- });
335
+ const newCol = valIndices.map((valIdx) => col[valIdx]);
560
336
  splitDataSources[val].primary.data.columns.push(newCol);
561
337
  }
562
338
  });
563
339
  });
564
340
  } else {
565
- errorCode = 'INVALID_SPLIT_BY_FIELD';
341
+ errorCode = "INVALID_SPLIT_BY_FIELD";
566
342
  }
567
-
568
- return {
569
- splitDataSources: splitDataSources,
570
- errorCode: errorCode
571
- };
343
+ return { splitDataSources, errorCode };
572
344
  };
573
-
574
- exports.dataSourcesSplitByModeStatsorUnknown = dataSourcesSplitByModeStatsorUnknown;
575
-
576
- var getTrellisDataSourcesBySplitMode = function getTrellisDataSourcesBySplitMode(splitMode, dataSources, trellisSplitBy) {
577
- var result = null;
578
-
345
+ var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
346
+ let result = null;
579
347
  try {
580
- if (splitMode === trellisUtils_1.TIMECHART) {
581
- result = trellisSplitBy === exports.AGGREGATIONS ? (0, exports.dataSourcesSplitByAggregationsTimechartAndChart)(dataSources) : (0, exports.dataSourcesSplitByModeTimechart)(dataSources, trellisSplitBy);
582
- } else if (splitMode === trellisUtils_1.STATS) {
583
- result = trellisSplitBy === exports.AGGREGATIONS ? (0, exports.dataSourcesSplitByAggregationsStats)(dataSources) : (0, exports.dataSourcesSplitByModeStatsorUnknown)(dataSources, trellisSplitBy, trellisUtils_1.STATS);
584
- } else if (splitMode === trellisUtils_1.CHART) {
585
- result = trellisSplitBy === exports.AGGREGATIONS ? (0, exports.dataSourcesSplitByAggregationsTimechartAndChart)(dataSources) : (0, exports.dataSourcesSplitByModeChart)(dataSources, trellisSplitBy);
586
- } else if (splitMode === trellisUtils_1.UNKNOWN) {
587
- result = trellisSplitBy === exports.AGGREGATIONS ? (0, exports.dataSourcesSplitByAggregationsUnknown)(dataSources) : (0, exports.dataSourcesSplitByModeStatsorUnknown)(dataSources, trellisSplitBy, trellisUtils_1.UNKNOWN);
348
+ if (splitMode === trellisUtils_exports.TIMECHART) {
349
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
350
+ } else if (splitMode === trellisUtils_exports.STATS) {
351
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
352
+ } else if (splitMode === trellisUtils_exports.CHART) {
353
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
354
+ } else if (splitMode === trellisUtils_exports.UNKNOWN) {
355
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
588
356
  }
589
357
  } catch (ex) {
590
- // eslint-disable-next-line no-console
591
- console.error('getTrellisDataSourcesBySplitMode ', ex);
592
- result = {
593
- splitDataSources: null,
594
- errorCode: 'UNKNOWN'
595
- };
358
+ console.error("getTrellisDataSourcesBySplitMode ", ex);
359
+ result = { splitDataSources: null, errorCode: "UNKNOWN" };
596
360
  }
597
-
598
361
  return result;
599
362
  };
600
-
601
- exports.getTrellisDataSourcesBySplitMode = getTrellisDataSourcesBySplitMode;
602
-
603
- /***/ }),
604
-
605
- /***/ 59:
606
- /***/ (function(module, exports) {
607
-
608
- module.exports = require("@splunk/visualizations-shared/trellisUtils");
609
-
610
- /***/ })
611
-
612
- /******/ });
613
- //# sourceMappingURL=trellisUtils.js.map
363
+ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
364
+ if (isTrellisOn && !options.legendDisplay) {
365
+ return {
366
+ legendDisplay: "off"
367
+ };
368
+ }
369
+ return {};
370
+ };
371
+ var calculateSharedMinMax = (splitData) => {
372
+ let max = -Infinity;
373
+ let min = Infinity;
374
+ Object.keys(splitData).forEach((splitByKey) => {
375
+ const datasources = splitData[splitByKey];
376
+ Object.keys(datasources).forEach((datasourceName) => {
377
+ const dataColumns = datasources[datasourceName].data.columns;
378
+ dataColumns.forEach((column) => {
379
+ column.forEach((point) => {
380
+ const pointNumber = Number(point);
381
+ if (pointNumber > max) {
382
+ max = pointNumber;
383
+ }
384
+ if (pointNumber < min) {
385
+ min = pointNumber;
386
+ }
387
+ });
388
+ });
389
+ });
390
+ });
391
+ return [min, max];
392
+ };
393
+ var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
394
+ if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")
395
+ return [yAxisMin, yAxisMax];
396
+ const [sharedMin, sharedMax] = calculateSharedMinMax(splitData);
397
+ const shouldUseSharedMax = sharedMax !== -Infinity && yAxisMax === "auto";
398
+ const shouldUseSharedMin = sharedMin !== Infinity && yAxisMin === "auto";
399
+ return [shouldUseSharedMin ? sharedMin : yAxisMin, shouldUseSharedMax ? sharedMax : yAxisMax];
400
+ };
401
+ //# sourceMappingURL=trellisUtils.js.map