@splunk/visualizations 26.4.1 → 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.
- package/Area.config.js +1262 -1600
- package/Area.config.js.map +7 -1
- package/Area.js +3002 -4930
- package/Area.js.map +7 -1
- package/Bar.config.js +1247 -1574
- package/Bar.config.js.map +7 -1
- package/Bar.js +2921 -4843
- package/Bar.js.map +7 -1
- package/Bubble.config.js +896 -1213
- package/Bubble.config.js.map +7 -1
- package/Bubble.js +2517 -4483
- package/Bubble.js.map +7 -1
- package/ChoroplethSvg.config.js +282 -582
- package/ChoroplethSvg.config.js.map +7 -1
- package/ChoroplethSvg.js +2004 -3810
- package/ChoroplethSvg.js.map +7 -1
- package/Column.config.js +1208 -1541
- package/Column.config.js.map +7 -1
- package/Column.js +2930 -4886
- package/Column.js.map +7 -1
- package/Ellipse.config.js +443 -774
- package/Ellipse.config.js.map +7 -1
- package/Ellipse.js +1651 -3341
- package/Ellipse.js.map +7 -1
- package/Events.config.js +207 -492
- package/Events.config.js.map +7 -1
- package/Events.js +2615 -4649
- package/Events.js.map +7 -1
- package/FillerGauge.config.js +420 -775
- package/FillerGauge.config.js.map +7 -1
- package/FillerGauge.js +2137 -4578
- package/FillerGauge.js.map +7 -1
- package/Image.config.js +144 -411
- package/Image.config.js.map +7 -1
- package/Image.js +1395 -3048
- package/Image.js.map +7 -1
- package/Line.config.js +1278 -1625
- package/Line.config.js.map +7 -1
- package/Line.js +2954 -4926
- package/Line.js.map +7 -1
- package/LinkGraph.config.js +390 -632
- package/LinkGraph.config.js.map +7 -1
- package/LinkGraph.js +5243 -6190
- package/LinkGraph.js.map +7 -1
- package/MIGRATION.md +6 -0
- package/Map.config.js +501 -801
- package/Map.config.js.map +7 -1
- package/Map.js +3369 -5676
- package/Map.js.map +7 -1
- package/Markdown.config.js +232 -528
- package/Markdown.config.js.map +7 -1
- package/Markdown.js +1645 -3216
- package/Markdown.js.map +7 -1
- package/MarkerGauge.config.js +308 -613
- package/MarkerGauge.config.js.map +7 -1
- package/MarkerGauge.js +2189 -4535
- package/MarkerGauge.js.map +7 -1
- package/ParallelCoordinates.config.js +282 -581
- package/ParallelCoordinates.config.js.map +7 -1
- package/ParallelCoordinates.js +2023 -4720
- package/ParallelCoordinates.js.map +7 -1
- package/Pie.config.js +278 -547
- package/Pie.config.js.map +7 -1
- package/Pie.js +1996 -3990
- package/Pie.js.map +7 -1
- package/Punchcard.config.js +291 -578
- package/Punchcard.config.js.map +7 -1
- package/Punchcard.js +2709 -5042
- package/Punchcard.js.map +7 -1
- package/Rectangle.config.js +455 -770
- package/Rectangle.config.js.map +7 -1
- package/Rectangle.js +1638 -3262
- package/Rectangle.js.map +7 -1
- package/Sankey.config.js +291 -626
- package/Sankey.config.js.map +7 -1
- package/Sankey.js +2737 -4909
- package/Sankey.js.map +7 -1
- package/Scatter.config.js +876 -1194
- package/Scatter.config.js.map +7 -1
- package/Scatter.js +2529 -4477
- package/Scatter.js.map +7 -1
- package/SingleValue.config.js +819 -1251
- package/SingleValue.config.js.map +7 -1
- package/SingleValue.js +4203 -7413
- package/SingleValue.js.map +7 -1
- package/SingleValueBasic.js +382 -1527
- package/SingleValueBasic.js.map +7 -1
- package/SingleValueIcon.config.js +781 -1207
- package/SingleValueIcon.config.js.map +7 -1
- package/SingleValueIcon.js +3350 -6285
- package/SingleValueIcon.js.map +7 -1
- package/SingleValueRadial.config.js +708 -1119
- package/SingleValueRadial.config.js.map +7 -1
- package/SingleValueRadial.js +3808 -6965
- package/SingleValueRadial.js.map +7 -1
- package/SparkLine.js +439 -746
- package/SparkLine.js.map +7 -1
- package/Table.config.js +565 -879
- package/Table.config.js.map +7 -1
- package/Table.js +3277 -5381
- package/Table.js.map +7 -1
- package/common/Charting.js +481 -1468
- package/common/Charting.js.map +7 -1
- package/common/ChartingApi.js +46 -170
- package/common/ChartingApi.js.map +7 -1
- package/common/DocExampleWithVizSandbox.js +270 -473
- package/common/DocExampleWithVizSandbox.js.map +7 -1
- package/common/EventsDoc.js +172 -464
- package/common/EventsDoc.js.map +7 -1
- package/common/GaugeMajorTicks.js +249 -347
- package/common/GaugeMajorTicks.js.map +7 -1
- package/common/GaugeValueMarker.js +201 -311
- package/common/GaugeValueMarker.js.map +7 -1
- package/common/OptionsDoc.js +347 -912
- package/common/OptionsDoc.js.map +7 -1
- package/common/OverviewDoc.js +435 -769
- package/common/OverviewDoc.js.map +7 -1
- package/common/SplunkVisualization.js +116 -259
- package/common/SplunkVisualization.js.map +7 -1
- package/common/SplunkVisualizationApi.js +40 -156
- package/common/SplunkVisualizationApi.js.map +7 -1
- package/common/ThemesDoc.js +271 -420
- package/common/ThemesDoc.js.map +7 -1
- package/common/chartingUtils.js +140 -312
- package/common/chartingUtils.js.map +7 -1
- package/common/docUtils.js +148 -266
- package/common/docUtils.js.map +7 -1
- package/common/gaugeUtils.js +280 -808
- package/common/gaugeUtils.js.map +7 -1
- package/common/shapeUtils.js +106 -211
- package/common/shapeUtils.js.map +7 -1
- package/common/utils/configUtils.js +126 -252
- package/common/utils/configUtils.js.map +7 -1
- package/common/utils/dataUtils.js +217 -812
- package/common/utils/dataUtils.js.map +7 -1
- package/common/utils/featureFlagUtils.js +53 -133
- package/common/utils/featureFlagUtils.js.map +7 -1
- package/common/utils/hocUtils.js +32 -122
- package/common/utils/hocUtils.js.map +7 -1
- package/common/utils/mapUtils.js +502 -1337
- package/common/utils/mapUtils.js.map +7 -1
- package/common/utils/singleValueUtils.js +462 -1010
- package/common/utils/singleValueUtils.js.map +7 -1
- package/common/utils/testHelper.js +92 -146
- package/common/utils/testHelper.js.map +7 -1
- package/common/utils/trellisUtils.js +237 -489
- package/common/utils/trellisUtils.js.map +7 -1
- package/common/utils/urlUtils.js +28 -112
- package/common/utils/urlUtils.js.map +7 -1
- package/common/withDashboardViz.js +1168 -2438
- package/common/withDashboardViz.js.map +7 -1
- package/package.json +52 -43
|
@@ -1,471 +1,262 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
var lodash_1 = __webpack_require__(0);
|
|
45
|
+
module.exports = __toCommonJS(trellisUtils_exports2);
|
|
123
46
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
65
|
+
// src/common/utils/trellisUtils.ts
|
|
66
|
+
var AGGREGATIONS = "aggregations";
|
|
67
|
+
var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
|
|
137
68
|
var _a, _b, _c, _d;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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 =
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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(
|
|
184
|
-
splitDataSources[splitByField] = (0,
|
|
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(
|
|
188
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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 =
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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(
|
|
239
|
-
splitDataSources[splitByField] = (0,
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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 = [
|
|
298
|
-
dataSourceKeys.forEach(
|
|
299
|
-
fields.forEach(
|
|
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(
|
|
195
|
+
splitDataSources[val].primary.data.columns.push([...columns[idx]]);
|
|
302
196
|
}
|
|
303
197
|
});
|
|
304
198
|
});
|
|
305
199
|
});
|
|
306
200
|
} else {
|
|
307
|
-
errorCode =
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
splitDataSources[val].primary.data.fields
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
|
|
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
|
-
|
|
463
|
-
|
|
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
|
-
|
|
479
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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 = [
|
|
495
|
-
dataSourceKeys.forEach(
|
|
496
|
-
fields.forEach(
|
|
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(
|
|
287
|
+
splitDataSources[val].primary.data.columns.push([...columns[idx]]);
|
|
499
288
|
}
|
|
500
289
|
});
|
|
501
290
|
});
|
|
502
291
|
});
|
|
503
292
|
}
|
|
504
293
|
} else {
|
|
505
|
-
errorCode =
|
|
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
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
-
|
|
534
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
321
|
+
const cloneFields = (0, lodash_exports.cloneDeep)(fields);
|
|
548
322
|
cloneFields.splice(splitByIndex, 1);
|
|
549
|
-
|
|
550
|
-
valueKeys.forEach(
|
|
551
|
-
|
|
552
|
-
splitDataSources[val] = (0,
|
|
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(
|
|
331
|
+
columns.forEach((col, idx) => {
|
|
556
332
|
if (idx !== splitByIndex) {
|
|
557
|
-
|
|
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 =
|
|
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
|
-
|
|
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 ===
|
|
581
|
-
result = trellisSplitBy ===
|
|
582
|
-
} else if (splitMode ===
|
|
583
|
-
result = trellisSplitBy ===
|
|
584
|
-
} else if (splitMode ===
|
|
585
|
-
result = trellisSplitBy ===
|
|
586
|
-
} else if (splitMode ===
|
|
587
|
-
result = trellisSplitBy ===
|
|
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
|
-
|
|
591
|
-
|
|
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
|