@splunk/visualizations 26.4.0 → 27.0.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 (152) hide show
  1. package/Area.config.js +1262 -1600
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3002 -4920
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1247 -1574
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +2924 -4836
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +896 -1213
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2520 -4476
  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 +2004 -3810
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1208 -1541
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +2933 -4879
  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 +1651 -3341
  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 +2615 -4649
  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 +2137 -4578
  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 +1395 -3048
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1278 -1625
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +2957 -4919
  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 +5243 -6190
  44. package/LinkGraph.js.map +7 -1
  45. package/MIGRATION.md +12 -0
  46. package/Map.config.js +501 -801
  47. package/Map.config.js.map +7 -1
  48. package/Map.js +3369 -5676
  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 +1645 -3216
  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 +2189 -4535
  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 +2023 -4720
  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 +1998 -3982
  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 +2709 -5042
  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 +1638 -3262
  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 +2737 -4909
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +876 -1194
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2532 -4470
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +819 -1251
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4203 -7413
  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 +781 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3350 -6285
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +708 -1119
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3808 -6965
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/Table.config.js +565 -887
  99. package/Table.config.js.map +7 -1
  100. package/Table.js +3277 -5386
  101. package/Table.js.map +7 -1
  102. package/common/Charting.js +484 -1462
  103. package/common/Charting.js.map +7 -1
  104. package/common/ChartingApi.js +46 -170
  105. package/common/ChartingApi.js.map +7 -1
  106. package/common/DocExampleWithVizSandbox.js +270 -473
  107. package/common/DocExampleWithVizSandbox.js.map +7 -1
  108. package/common/EventsDoc.js +172 -464
  109. package/common/EventsDoc.js.map +7 -1
  110. package/common/GaugeMajorTicks.js +249 -347
  111. package/common/GaugeMajorTicks.js.map +7 -1
  112. package/common/GaugeValueMarker.js +201 -311
  113. package/common/GaugeValueMarker.js.map +7 -1
  114. package/common/OptionsDoc.js +347 -912
  115. package/common/OptionsDoc.js.map +7 -1
  116. package/common/OverviewDoc.js +435 -769
  117. package/common/OverviewDoc.js.map +7 -1
  118. package/common/SplunkVisualization.js +116 -259
  119. package/common/SplunkVisualization.js.map +7 -1
  120. package/common/SplunkVisualizationApi.js +40 -156
  121. package/common/SplunkVisualizationApi.js.map +7 -1
  122. package/common/ThemesDoc.js +271 -420
  123. package/common/ThemesDoc.js.map +7 -1
  124. package/common/chartingUtils.js +140 -312
  125. package/common/chartingUtils.js.map +7 -1
  126. package/common/docUtils.js +148 -266
  127. package/common/docUtils.js.map +7 -1
  128. package/common/gaugeUtils.js +280 -808
  129. package/common/gaugeUtils.js.map +7 -1
  130. package/common/shapeUtils.js +106 -211
  131. package/common/shapeUtils.js.map +7 -1
  132. package/common/utils/configUtils.js +126 -252
  133. package/common/utils/configUtils.js.map +7 -1
  134. package/common/utils/dataUtils.js +217 -812
  135. package/common/utils/dataUtils.js.map +7 -1
  136. package/common/utils/featureFlagUtils.js +53 -133
  137. package/common/utils/featureFlagUtils.js.map +7 -1
  138. package/common/utils/hocUtils.js +32 -122
  139. package/common/utils/hocUtils.js.map +7 -1
  140. package/common/utils/mapUtils.js +502 -1337
  141. package/common/utils/mapUtils.js.map +7 -1
  142. package/common/utils/singleValueUtils.js +462 -1010
  143. package/common/utils/singleValueUtils.js.map +7 -1
  144. package/common/utils/testHelper.js +92 -146
  145. package/common/utils/testHelper.js.map +7 -1
  146. package/common/utils/trellisUtils.js +237 -489
  147. package/common/utils/trellisUtils.js.map +7 -1
  148. package/common/utils/urlUtils.js +28 -112
  149. package/common/utils/urlUtils.js.map +7 -1
  150. package/common/withDashboardViz.js +1168 -2438
  151. package/common/withDashboardViz.js.map +7 -1
  152. package/package.json +52 -43
@@ -1,471 +1,262 @@
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
+ getTrellisDataSourcesBySplitMode: () => getTrellisDataSourcesBySplitMode
119
44
  });
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);
45
+ module.exports = __toCommonJS(trellisUtils_exports2);
123
46
 
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
- */
47
+ // esm-externals:lodash
48
+ var lodash_exports = {};
49
+ __export(lodash_exports, {
50
+ default: () => lodash_default
51
+ });
52
+ var defaultImport = __toESM(require("lodash"));
53
+ __reExport(lodash_exports, require("lodash"));
54
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
55
+
56
+ // esm-externals:@splunk/visualizations-shared/trellisUtils
57
+ var trellisUtils_exports = {};
58
+ __export(trellisUtils_exports, {
59
+ default: () => trellisUtils_default
60
+ });
61
+ var defaultImport2 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
62
+ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
63
+ var trellisUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
135
64
 
136
- var dataSourcesSplitByAggregationsUnknown = function dataSourcesSplitByAggregationsUnknown(dataSource) {
65
+ // src/common/utils/trellisUtils.ts
66
+ var AGGREGATIONS = "aggregations";
67
+ var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
137
68
  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
-
69
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
70
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
71
+ let splitDataSources = null;
72
+ let errorCode = null;
144
73
  if (fields && fields.length) {
145
74
  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']));
75
+ for (let i = 0; i < fields.length; i += 1) {
76
+ const fieldName = fields[i].name;
77
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
78
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
79
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
80
+ );
152
81
  splitDataSources[fieldName].primary.data.fields = [fields[i]];
153
82
  splitDataSources[fieldName].primary.data.columns = [columns[i]];
154
83
  }
155
84
  }
156
85
  } else {
157
- errorCode = 'INVALID_SPLIT_BY_FIELD';
86
+ errorCode = "INVALID_SPLIT_BY_FIELD";
158
87
  }
159
-
160
- return {
161
- splitDataSources: splitDataSources,
162
- errorCode: errorCode
163
- };
88
+ return { splitDataSources, errorCode };
164
89
  };
165
-
166
- exports.dataSourcesSplitByAggregationsUnknown = dataSourcesSplitByAggregationsUnknown;
167
-
168
- var dataSourcesSplitByAggregationsTimechartAndChart = function dataSourcesSplitByAggregationsTimechartAndChart(dataSource) {
90
+ var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
169
91
  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);
92
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
93
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
94
+ let splitDataSources = null;
95
+ let splitByFields = [];
96
+ let errorCode = null;
97
+ if (typeof fields[0] !== "string") {
98
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
179
99
  }
180
-
181
100
  if (splitByFields && splitByFields.length > 0) {
182
101
  splitDataSources = {};
183
- splitByFields.forEach(function (splitByField) {
184
- splitDataSources[splitByField] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
102
+ splitByFields.forEach((splitByField) => {
103
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
104
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
105
+ );
185
106
  splitDataSources[splitByField].primary.data.fields = [fields[0]];
186
107
  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) {
108
+ fields.forEach((field, idx) => {
109
+ const fieldName = field == null ? void 0 : field.name;
110
+ if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
191
111
  splitDataSources[splitByField].primary.data.fields.push(field);
192
112
  splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
193
113
  }
194
114
  });
195
115
  });
196
116
  } 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
117
  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']));
118
+ for (let i = 1; i < fields.length; i += 1) {
119
+ const fieldName = fields[i].name;
120
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
121
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
122
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
123
+ );
207
124
  splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
208
125
  splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
209
126
  }
210
127
  }
211
128
  } else {
212
- errorCode = 'INVALID_SPLIT_BY_FIELD';
129
+ errorCode = "INVALID_SPLIT_BY_FIELD";
213
130
  }
214
-
215
- return {
216
- splitDataSources: splitDataSources,
217
- errorCode: errorCode
218
- };
131
+ return { splitDataSources, errorCode };
219
132
  };
220
-
221
- exports.dataSourcesSplitByAggregationsTimechartAndChart = dataSourcesSplitByAggregationsTimechartAndChart;
222
-
223
- var dataSourcesSplitByAggregationsStats = function dataSourcesSplitByAggregationsStats(dataSource) {
133
+ var dataSourcesSplitByAggregationsStats = (dataSource) => {
224
134
  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);
135
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
136
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
137
+ let splitDataSources = null;
138
+ let splitByFields = [];
139
+ let errorCode = null;
140
+ if (typeof fields[0] !== "string") {
141
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
234
142
  }
235
-
236
143
  if (splitByFields && splitByFields.length > 0) {
237
144
  splitDataSources = {};
238
- splitByFields.forEach(function (splitByField) {
239
- splitDataSources[splitByField] = (0, lodash_1.cloneDeep)((0, lodash_1.omit)(dataSource, ['primary.data.fields', 'primary.data.columns']));
145
+ splitByFields.forEach((splitByField) => {
146
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
147
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
148
+ );
240
149
  splitDataSources[splitByField].primary.data.fields = [fields[0]];
241
150
  splitDataSources[splitByField].primary.data.columns = [columns[0]];
242
- var idx = fields.findIndex(function (field) {
243
- return field.name === splitByField;
244
- });
245
-
151
+ const idx = fields.findIndex((field) => field.name === splitByField);
246
152
  if (idx > 0) {
247
153
  splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
248
154
  splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
249
155
  }
250
156
  });
251
157
  } else {
252
- errorCode = 'INVALID_SPLIT_BY_FIELD';
158
+ errorCode = "INVALID_SPLIT_BY_FIELD";
253
159
  }
254
-
255
- return {
256
- splitDataSources: splitDataSources,
257
- errorCode: errorCode
258
- };
160
+ return { splitDataSources, errorCode };
259
161
  };
260
-
261
- exports.dataSourcesSplitByAggregationsStats = dataSourcesSplitByAggregationsStats;
262
-
263
- var dataSourcesSplitByModeTimechart = function dataSourcesSplitByModeTimechart(dataSource, splitBy) {
162
+ var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
264
163
  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);
164
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
165
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
166
+ let splitDataSources = null;
167
+ let splitByFields = [];
168
+ let errorCode = null;
169
+ if (typeof fields[0] !== "string") {
170
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
274
171
  }
275
-
276
172
  if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
277
173
  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('_'))) {
174
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
175
+ const valueKeys = [];
176
+ for (let i = 1; i < fields.length; i += 1) {
177
+ if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
284
178
  valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
285
179
  }
286
180
  }
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 {
181
+ valueKeys.forEach((val) => {
182
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
183
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
184
+ );
185
+ splitDataSources[val].primary.data.fields = [
186
+ { name: fields[0].name },
187
+ ...dataSourceKeys.map((k) => ({
294
188
  name: k
295
- };
296
- })));
297
- splitDataSources[val].primary.data.columns = [_toConsumableArray(columns[0])];
298
- dataSourceKeys.forEach(function (dsKey) {
299
- fields.forEach(function (field, idx) {
189
+ }))
190
+ ];
191
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
192
+ dataSourceKeys.forEach((dsKey) => {
193
+ fields.forEach((field, idx) => {
300
194
  if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
301
- splitDataSources[val].primary.data.columns.push(_toConsumableArray(columns[idx]));
195
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
302
196
  }
303
197
  });
304
198
  });
305
199
  });
306
200
  } else {
307
- errorCode = 'INVALID_SPLIT_BY_FIELD';
201
+ errorCode = "INVALID_SPLIT_BY_FIELD";
308
202
  }
309
-
310
- return {
311
- splitDataSources: splitDataSources,
312
- errorCode: errorCode
313
- };
203
+ return { splitDataSources, errorCode };
314
204
  };
315
-
316
- exports.dataSourcesSplitByModeTimechart = dataSourcesSplitByModeTimechart;
317
-
318
- var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSource, splitBy) {
205
+ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
319
206
  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);
207
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
208
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
209
+ let splitDataSources = null;
210
+ let splitByFields = [];
211
+ let errorCode = null;
212
+ if (typeof fields[0] !== "string") {
213
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
329
214
  }
330
-
331
215
  if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
332
216
  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) {
217
+ const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
218
+ const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
219
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
220
+ const nonDataSourceAggregations = [];
221
+ if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
222
+ for (let i = 1; i < fields.length; i += 1) {
363
223
  nonDataSourceAggregations.push(fields[i].name);
364
224
  }
365
225
  }
366
-
367
226
  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']));
227
+ const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
228
+ valueKeys.forEach((val, idx) => {
229
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
230
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
231
+ );
372
232
  splitDataSources[val].primary.data.fields = [];
373
-
374
233
  if (otherSplitBy.length) {
375
- splitDataSources[val].primary.data.fields = [{
376
- name: otherSplitBy[0]
377
- }]; // there can only be one otherSplitBy for chart cmd
234
+ splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
378
235
  }
379
-
380
236
  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([]);
237
+ const columnValues = [[]];
238
+ splitDataSources[val].primary.data.fields = [
239
+ ...splitDataSources[val].primary.data.fields,
240
+ ...dataSourceKeys.map((k) => ({
241
+ name: k
242
+ }))
243
+ ];
244
+ dataSourceKeys.forEach(() => {
245
+ columnValues.push([]);
246
+ });
247
+ for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
248
+ columnValues[0].push(
249
+ fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
250
+ );
251
+ dataSourceKeys.forEach((dskey, dsIndx) => {
252
+ const mul = (fields.length - 1) / dataSourceKeys.length;
253
+ columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
390
254
  });
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
- })();
255
+ }
256
+ splitDataSources[val].primary.data.columns = columnValues;
461
257
  } 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) {
258
+ const columnValues = [];
259
+ fields.forEach((aggregationField, fieldIdx) => {
469
260
  if (fieldIdx > 0) {
470
261
  splitDataSources[val].primary.data.fields.push(aggregationField);
471
262
  columnValues.push([columns[fieldIdx][idx]]);
@@ -475,139 +266,96 @@ var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSourc
475
266
  }
476
267
  });
477
268
  } 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);
269
+ const valueKeys = [];
270
+ for (let i = 1; i < fields.length; i += 1) {
271
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
483
272
  }
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 {
273
+ valueKeys.forEach((val) => {
274
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
275
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
276
+ );
277
+ splitDataSources[val].primary.data.fields = [
278
+ { name: otherSplitBy[0] },
279
+ ...dataSourceKeys.map((k) => ({
491
280
  name: k
492
- };
493
- })));
494
- splitDataSources[val].primary.data.columns = [_toConsumableArray(columns[0])];
495
- dataSourceKeys.forEach(function (dsKey) {
496
- fields.forEach(function (field, idx) {
281
+ }))
282
+ ];
283
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
284
+ dataSourceKeys.forEach((dsKey) => {
285
+ fields.forEach((field, idx) => {
497
286
  if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
498
- splitDataSources[val].primary.data.columns.push(_toConsumableArray(columns[idx]));
287
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
499
288
  }
500
289
  });
501
290
  });
502
291
  });
503
292
  }
504
293
  } else {
505
- errorCode = 'INVALID_SPLIT_BY_FIELD';
294
+ errorCode = "INVALID_SPLIT_BY_FIELD";
506
295
  }
507
-
508
- return {
509
- splitDataSources: splitDataSources,
510
- errorCode: errorCode
511
- };
296
+ return { splitDataSources, errorCode };
512
297
  };
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) {
298
+ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
521
299
  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);
300
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
301
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
302
+ let splitDataSources = null;
303
+ let splitByFields = [];
304
+ let errorCode = null;
305
+ if (typeof fields[0] !== "string") {
306
+ splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
531
307
  }
532
-
533
- var splitByIndex = fields === null || fields === void 0 ? void 0 : fields.findIndex(function (field) {
534
- return field === splitBy || field.name === splitBy;
535
- });
536
-
308
+ const splitByIndex = fields == null ? void 0 : fields.findIndex(
309
+ (field) => field === splitBy || field.name === splitBy
310
+ );
537
311
  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];
312
+ const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
539
313
  splitDataSources = {};
540
- splitByColumn.forEach(function (val, idx) {
314
+ splitByColumn.forEach((val, idx) => {
541
315
  if (!splitDataSources[val]) {
542
316
  splitDataSources[val] = [idx];
543
317
  } else {
544
318
  splitDataSources[val].push(idx);
545
319
  }
546
320
  });
547
- var cloneFields = (0, lodash_1.cloneDeep)(fields);
321
+ const cloneFields = (0, lodash_exports.cloneDeep)(fields);
548
322
  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']));
323
+ const valueKeys = Object.keys(splitDataSources);
324
+ valueKeys.forEach((val) => {
325
+ const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
326
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
327
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
328
+ );
553
329
  splitDataSources[val].primary.data.fields = cloneFields;
554
330
  splitDataSources[val].primary.data.columns = [];
555
- columns.forEach(function (col, idx) {
331
+ columns.forEach((col, idx) => {
556
332
  if (idx !== splitByIndex) {
557
- var newCol = valIndices.map(function (valIdx) {
558
- return col[valIdx];
559
- });
333
+ const newCol = valIndices.map((valIdx) => col[valIdx]);
560
334
  splitDataSources[val].primary.data.columns.push(newCol);
561
335
  }
562
336
  });
563
337
  });
564
338
  } else {
565
- errorCode = 'INVALID_SPLIT_BY_FIELD';
339
+ errorCode = "INVALID_SPLIT_BY_FIELD";
566
340
  }
567
-
568
- return {
569
- splitDataSources: splitDataSources,
570
- errorCode: errorCode
571
- };
341
+ return { splitDataSources, errorCode };
572
342
  };
573
-
574
- exports.dataSourcesSplitByModeStatsorUnknown = dataSourcesSplitByModeStatsorUnknown;
575
-
576
- var getTrellisDataSourcesBySplitMode = function getTrellisDataSourcesBySplitMode(splitMode, dataSources, trellisSplitBy) {
577
- var result = null;
578
-
343
+ var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
344
+ let result = null;
579
345
  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);
346
+ if (splitMode === trellisUtils_exports.TIMECHART) {
347
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
348
+ } else if (splitMode === trellisUtils_exports.STATS) {
349
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
350
+ } else if (splitMode === trellisUtils_exports.CHART) {
351
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
352
+ } else if (splitMode === trellisUtils_exports.UNKNOWN) {
353
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
588
354
  }
589
355
  } catch (ex) {
590
- // eslint-disable-next-line no-console
591
- console.error('getTrellisDataSourcesBySplitMode ', ex);
592
- result = {
593
- splitDataSources: null,
594
- errorCode: 'UNKNOWN'
595
- };
356
+ console.error("getTrellisDataSourcesBySplitMode ", ex);
357
+ result = { splitDataSources: null, errorCode: "UNKNOWN" };
596
358
  }
597
-
598
359
  return result;
599
360
  };
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
361
+ //# sourceMappingURL=trellisUtils.js.map