@splunk/visualization-migrations 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.
package/index.js CHANGED
@@ -1,385 +1,346 @@
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 = 10);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ([
94
- /* 0 */
95
- /***/ (function(module, exports) {
96
-
97
- module.exports = require("@splunk/visualization-schemas");
98
-
99
- /***/ }),
100
- /* 1 */
101
- /***/ (function(module, exports, __webpack_require__) {
102
-
103
- "use strict";
104
-
105
-
106
- var _slicedToArray = __webpack_require__(7);
107
-
108
- Object.defineProperty(exports, "__esModule", {
109
- 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 __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
+
62
+ // src/index.ts
63
+ var src_exports = {};
64
+ __export(src_exports, {
65
+ canMigrate: () => canMigrate,
66
+ encodingToDynamicOptionsDSL: () => encodingToDynamicOptionsDSL,
67
+ inferToType: () => inferToType,
68
+ migrate: () => migrate
110
69
  });
111
- exports.addsDataSelectorToOptions = exports.preserveDataSelectionForValueOption = exports.renameVizOptions = exports.removeInvalidOptions = void 0;
70
+ module.exports = __toCommonJS(src_exports);
112
71
 
113
- var dsl_1 = __webpack_require__(19);
114
- /**
115
- * Removes invalid keys in the options
116
- * @param currentOptions - Current visualization options
117
- * @param validOptions - Valid visualization option keys
118
- * @returns void
119
- */
120
-
121
-
122
- var removeInvalidOptions = function removeInvalidOptions(currentOptions, validOptions) {
123
- if (!currentOptions || !validOptions) {
124
- return;
125
- }
72
+ // esm-externals:@splunk/visualization-schemas
73
+ var visualization_schemas_exports = {};
74
+ __export(visualization_schemas_exports, {
75
+ default: () => visualization_schemas_default
76
+ });
77
+ var defaultImport = __toESM(require("@splunk/visualization-schemas"));
78
+ __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
79
+ var visualization_schemas_default = "default" in defaultImport ? defaultImport.default : defaultImport;
80
+
81
+ // esm-externals:@splunk/visualization-encoding/utils/parserUtils
82
+ var parserUtils_exports = {};
83
+ __export(parserUtils_exports, {
84
+ default: () => parserUtils_default
85
+ });
86
+ var defaultImport2 = __toESM(require("@splunk/visualization-encoding/utils/parserUtils"));
87
+ __reExport(parserUtils_exports, require("@splunk/visualization-encoding/utils/parserUtils"));
88
+ var parserUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
126
89
 
127
- var copiedCurrOptions = currentOptions;
128
- Object.keys(copiedCurrOptions).forEach(function (key) {
129
- if (!(key in validOptions)) {
130
- delete copiedCurrOptions[key];
90
+ // src/encoding/encoding.ts
91
+ var indexBasedRegx = /^[A-Za-z0-9_]+\[.*\].*$/;
92
+ var nameBasedRegx = /^[A-Za-z0-9_]+\..*$/;
93
+ var isIndexBasedReference = (ref) => indexBasedRegx.test(ref);
94
+ var isNameBasedReference = (ref) => nameBasedRegx.test(ref);
95
+ var convertFormatterToDSL = (fieldReference, key, translatedValue) => {
96
+ var _a, _b, _c, _d, _e, _f;
97
+ switch ((_a = fieldReference == null ? void 0 : fieldReference.format) == null ? void 0 : _a.type) {
98
+ case "gradient":
99
+ return {
100
+ contextConfig: __spreadValues(__spreadValues({}, Array.isArray((_b = fieldReference.format) == null ? void 0 : _b.ranges) && {
101
+ stops: [...fieldReference.format.ranges]
102
+ }), Array.isArray((_c = fieldReference.format) == null ? void 0 : _c.values) && {
103
+ colors: [...fieldReference.format.values]
104
+ }),
105
+ contextKey: `${key}GradientContext`,
106
+ dsl: `${translatedValue} | gradient(${key}GradientContext)`
107
+ };
108
+ case "rangevalue": {
109
+ const contextKey = `${key}RangeValueContext`;
110
+ return {
111
+ contextConfig: ((_d = fieldReference.format) == null ? void 0 : _d.ranges) || [],
112
+ contextKey,
113
+ dsl: `${translatedValue} | rangeValue(${contextKey})`
114
+ };
131
115
  }
132
- });
133
- };
134
-
135
- exports.removeInvalidOptions = removeInvalidOptions;
136
- /**
137
- * Renames viz options by looking up their migration mapping
138
- * @param oldOptions - Current visualization options
139
- * @param optionRenames - Mapping of old options in viz.X to their migrated counterparts in splunk.X
140
- * @returns updatedOptions
141
- */
142
-
143
- var renameVizOptions = function renameVizOptions(oldOptions, optionRenames) {
144
- var updatedOptions = {};
145
- if (!oldOptions) return {};
146
- if (!optionRenames) return oldOptions;
147
- Object.entries(oldOptions).forEach(function (_ref) {
148
- var _ref2 = _slicedToArray(_ref, 2),
149
- oldOptName = _ref2[0],
150
- val = _ref2[1];
151
-
152
- var _a;
153
-
154
- var optionName = (_a = optionRenames[oldOptName]) !== null && _a !== void 0 ? _a : oldOptName;
155
- updatedOptions[optionName] = val;
156
- });
157
- return updatedOptions;
158
- };
159
-
160
- exports.renameVizOptions = renameVizOptions;
161
- /**
162
- * Appends appropriate series selector to DSL string to add viz-specific implicit logic
163
- * @param valueOption - the value of an option
164
- * @param selector - the selector to append
165
- * @returns string | void
166
- */
167
-
168
- var preserveDataSelectionForValueOption = function preserveDataSelectionForValueOption(valueOption, selector) {
169
- if (valueOption) {
170
- // if the last data selector starts with seriesBy, append appropriate selector to it
171
- var dataSelectors = (0, dsl_1.getDataSelectorsFromDSL)(valueOption);
172
- var lastDataSelector = dataSelectors[dataSelectors.length - 1];
173
-
174
- if (lastDataSelector.includes('seriesByIndex') || lastDataSelector.includes('seriesByName')) {
175
- return "".concat(valueOption, " | ").concat(selector);
116
+ case "matchvalue": {
117
+ const defaultValue = (_e = fieldReference.format) == null ? void 0 : _e.defaultValue;
118
+ const matchValueContextKey = `${key}MatchValueContext`;
119
+ return {
120
+ contextConfig: ((_f = fieldReference.format) == null ? void 0 : _f.matches) || [],
121
+ contextKey: matchValueContextKey,
122
+ dsl: `${translatedValue} | matchValue(${matchValueContextKey}${defaultValue !== null && defaultValue !== void 0 ? `, ${typeof defaultValue === "string" ? `"${defaultValue}"` : defaultValue}` : ""})`
123
+ };
176
124
  }
125
+ default:
126
+ break;
177
127
  }
178
-
179
128
  return null;
180
129
  };
181
-
182
- exports.preserveDataSelectionForValueOption = preserveDataSelectionForValueOption;
183
- /**
184
- * For all data options, calls preserveDataSelectionForValueOption with relevant selector and
185
- * updates dataOptions object
186
- * @param dataOptions - an object reflecting all data options
187
- * @param selector - the selector to append
188
- * @returns void
189
- */
190
-
191
- var addsDataSelectorToOptions = function addsDataSelectorToOptions(dataOptions, selector) {
192
- var updatedDataOptions = {};
193
- Object.keys(dataOptions).forEach(function (key) {
194
- var statement = dataOptions[key];
195
- var updatedDSL = (0, exports.preserveDataSelectionForValueOption)(statement, selector);
196
-
197
- if (updatedDSL) {
198
- updatedDataOptions[key] = updatedDSL;
199
- } else {
200
- updatedDataOptions[key] = statement;
201
- }
202
- });
203
- return updatedDataOptions;
204
- };
205
-
206
- exports.addsDataSelectorToOptions = addsDataSelectorToOptions;
207
-
208
- /***/ }),
209
- /* 2 */
210
- /***/ (function(module, exports, __webpack_require__) {
211
-
212
- "use strict";
213
-
214
-
215
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
216
- if (k2 === undefined) k2 = k;
217
- var desc = Object.getOwnPropertyDescriptor(m, k);
218
-
219
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
220
- desc = {
221
- enumerable: true,
222
- get: function get() {
223
- return m[k];
224
- }
225
- };
130
+ var translateArrayFormatDataReference = (encodingDataReference) => {
131
+ if (encodingDataReference.length === 0) {
132
+ return null;
226
133
  }
227
-
228
- Object.defineProperty(o, k2, desc);
229
- } : function (o, m, k, k2) {
230
- if (k2 === undefined) k2 = k;
231
- o[k2] = m[k];
232
- });
233
-
234
- var __exportStar = this && this.__exportStar || function (m, exports) {
235
- for (var p in m) {
236
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
134
+ const allIndexBased = encodingDataReference.every(isIndexBasedReference);
135
+ const allNameBased = encodingDataReference.every(isNameBasedReference);
136
+ if (allIndexBased) {
137
+ const { dataSourceName: dataSourceName2 } = (0, parserUtils_exports.parseIndexBasedFieldReference)(encodingDataReference[0]);
138
+ const indexesStr = encodingDataReference.map((ref) => {
139
+ var _a;
140
+ return (_a = (0, parserUtils_exports.parseIndexBasedFieldReference)(ref)) == null ? void 0 : _a.fieldIndex;
141
+ }).join(",");
142
+ return `> ${dataSourceName2} | frameBySeriesIndexes(${indexesStr})`;
143
+ }
144
+ if (allNameBased) {
145
+ const { dataSourceName: dataSourceName2 } = (0, parserUtils_exports.parseNameBasedFieldReference)(encodingDataReference[0]);
146
+ const namesStr = encodingDataReference.map((ref) => {
147
+ var _a;
148
+ return `"${(_a = (0, parserUtils_exports.parseNameBasedFieldReference)(ref)) == null ? void 0 : _a.fieldName}"`;
149
+ }).join(",");
150
+ return `> ${dataSourceName2} | frameBySeriesNames(${namesStr})`;
237
151
  }
152
+ const firstEntry = encodingDataReference[0];
153
+ const { dataSourceName } = isIndexBasedReference(firstEntry) ? (0, parserUtils_exports.parseIndexBasedFieldReference)(firstEntry) : (0, parserUtils_exports.parseNameBasedFieldReference)(firstEntry);
154
+ const paramStr = encodingDataReference.map((ref) => {
155
+ var _a, _b;
156
+ return isIndexBasedReference(ref) ? (_a = (0, parserUtils_exports.parseIndexBasedFieldReference)(ref)) == null ? void 0 : _a.fieldIndex : `"${(_b = (0, parserUtils_exports.parseNameBasedFieldReference)(ref)) == null ? void 0 : _b.fieldName}"`;
157
+ }).join(",");
158
+ return `> ${dataSourceName} | frameBySeriesNamesOrIndexes(${paramStr})`;
238
159
  };
239
-
240
- Object.defineProperty(exports, "__esModule", {
241
- value: true
242
- });
243
-
244
- __exportStar(__webpack_require__(14), exports);
245
-
246
- /***/ }),
247
- /* 3 */
248
- /***/ (function(module, exports, __webpack_require__) {
249
-
250
- "use strict";
251
-
252
-
253
- var _typeof = __webpack_require__(5);
254
-
255
- var __rest = this && this.__rest || function (s, e) {
256
- var t = {};
257
-
258
- for (var p in s) {
259
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
160
+ var translateDataReference = (encodingDataReference) => {
161
+ if (encodingDataReference.indexOf("encoding.") === 0) {
162
+ return `> ${encodingDataReference.replace("encoding.", "")}`;
260
163
  }
261
-
262
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
263
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
164
+ const isIndexBasedRef = isIndexBasedReference(encodingDataReference);
165
+ const isNameBasedRef = isNameBasedReference(encodingDataReference);
166
+ if (!isIndexBasedRef && !isNameBasedRef) {
167
+ console.warn("Unable to parse the encoding. Please verify the encoding format is correct");
168
+ return null;
169
+ }
170
+ if (isNameBasedRef) {
171
+ const { dataSourceName, fieldName, columnIndex } = (0, parserUtils_exports.parseNameBasedFieldReference)(
172
+ encodingDataReference
173
+ );
174
+ let returnString = `> ${dataSourceName} | seriesByName("${fieldName}")`;
175
+ if (columnIndex) {
176
+ returnString += ` | pointByIndex(${columnIndex})`;
177
+ }
178
+ return returnString;
179
+ }
180
+ if (isIndexBasedRef) {
181
+ const {
182
+ dataSourceName,
183
+ fieldIndex,
184
+ columnIndex,
185
+ isFieldIndexRange,
186
+ fromFieldIndex,
187
+ toFieldIndex
188
+ } = (0, parserUtils_exports.parseIndexBasedFieldReference)(encodingDataReference);
189
+ if (isFieldIndexRange) {
190
+ let dslToIndexString;
191
+ if (toFieldIndex === -1) {
192
+ dslToIndexString = "";
193
+ } else {
194
+ dslToIndexString = `,${toFieldIndex + 1}`;
195
+ }
196
+ return `> ${dataSourceName} | frameBySeriesIndexRange(${fromFieldIndex}${dslToIndexString})`;
197
+ }
198
+ let returnString = `> ${dataSourceName} | seriesByIndex(${fieldIndex})`;
199
+ if (columnIndex) {
200
+ returnString += ` | pointByIndex(${columnIndex})`;
201
+ }
202
+ return returnString;
264
203
  }
265
- return t;
204
+ return null;
205
+ };
206
+ var encodingToDynamicOptionsDSL = (encoding) => {
207
+ const dynamicOptions = {
208
+ options: {},
209
+ context: {}
210
+ };
211
+ const translatedOptions = {};
212
+ const encodingObj = encoding != null ? encoding : {};
213
+ Object.keys(encodingObj).forEach((key) => {
214
+ const fieldReference = encoding[key];
215
+ let fieldReferenceStr = fieldReference;
216
+ if (typeof fieldReference === "object" && !Array.isArray(fieldReference)) {
217
+ const { field } = fieldReference;
218
+ if (field && !Array.isArray(field)) {
219
+ fieldReferenceStr = field;
220
+ }
221
+ }
222
+ let translatedValue;
223
+ if (Array.isArray(fieldReference)) {
224
+ translatedValue = translateArrayFormatDataReference(fieldReference);
225
+ } else {
226
+ translatedValue = translateDataReference(fieldReferenceStr);
227
+ }
228
+ if (translatedValue) {
229
+ translatedOptions[key] = translatedValue;
230
+ const convertedFormatterObject = convertFormatterToDSL(
231
+ fieldReference,
232
+ key,
233
+ translatedValue
234
+ );
235
+ if (convertedFormatterObject) {
236
+ translatedOptions[key] = convertedFormatterObject.dsl;
237
+ dynamicOptions.context[convertedFormatterObject.contextKey] = convertedFormatterObject.contextConfig;
238
+ }
239
+ }
240
+ });
241
+ dynamicOptions.options = translatedOptions;
242
+ return dynamicOptions;
266
243
  };
267
244
 
268
- Object.defineProperty(exports, "__esModule", {
269
- value: true
270
- });
271
- exports.otherValueReplacements = exports.migrateChartingOptions = exports.migrateBaseChartingVizDefinition = void 0;
272
-
273
- var encoding_1 = __webpack_require__(2);
274
- /**
275
- * map of splunk charting based @splunk/dashboard-visualization option names
276
- * to updated @splunk/visualization option names
277
- */
278
-
279
-
245
+ // src/visualizations/splunk-charting.ts
280
246
  var optionRenames = {
281
- 'axisTitleX.text': 'xAxisTitleText',
282
- 'axisTitleY.text': 'yAxisTitleText',
283
- 'axisTitleY2.text': 'y2AxisTitleText',
284
- 'axisTitleX.visibility': 'xAxisTitleVisibility',
285
- 'axisTitleY.visibility': 'yAxisTitleVisibility',
286
- 'axisTitleY2.visibility': 'y2AxisTitleVisibility',
287
- 'axisLabelsX.majorLabelStyle.rotation': 'xAxisLabelRotation',
288
- 'axisLabelsX.majorLabelVisibility': 'xAxisLabelVisibility',
289
- 'axisLabelsY.majorLabelVisibility': 'yAxisLabelVisibility',
290
- 'axisLabelsY2.majorLabelVisibility': 'y2AxisLabelVisibility',
291
- 'axisLabelsX.majorTickVisibility': 'xAxisMajorTickVisibility',
292
- 'axisLabelsY.majorTickVisibility': 'yAxisMajorTickVisibility',
293
- 'axisLabelsY2.majorTickVisibility': 'y2AxisMajorTickVisibility',
294
- 'axisLabelsX.minorTickVisibility': 'xAxisMinorTickVisibility',
295
- 'axisLabelsY.minorTickVisibility': 'yAxisMinorTickVisibility',
296
- 'axisLabelsY2.minorTickVisibility': 'y2AxisMinorTickVisibility',
297
- 'axisLabelsX.majorTickSize': 'xAxisMajorTickSize',
298
- 'axisLabelsY.majorTickSize': 'yAxisMajorTickSize',
299
- 'axisLabelsY2.majorTickSize': 'y2AxisMajorTickSize',
300
- 'axisLabelsX.minorTickSize': 'xAxisMinorTickSize',
301
- 'axisLabelsY.minorTickSize': 'yAxisMinorTickSize',
302
- 'axisLabelsY2.minorTickSize': 'y2AxisMinorTickSize',
303
- 'axisLabelsX.majorUnit': 'xAxisMajorTickInterval',
304
- 'axisLabelsY.majorUnit': 'yAxisMajorTickInterval',
305
- 'axisLabelsY2.majorUnit': 'y2AxisMajorTickInterval',
306
- 'axisX.abbreviation': 'xAxisAbbreviation',
307
- 'axisY.abbreviation': 'yAxisAbbreviation',
308
- 'axisY2.abbreviation': 'y2AxisAbbreviation',
309
- 'axisLabelsX.integerUnits': 'showRoundedXAxisLabels',
310
- 'axisLabelsY2.integerUnits': 'showRoundedY2AxisLabels',
311
- 'axisLabelsX.maxLabelParts': 'xAxisMaxLabelParts',
312
- 'axisLabelsX.axisVisibility': 'xAxisLineVisibility',
313
- 'axisLabelsY.axisVisibility': 'yAxisLineVisibility',
314
- 'axisLabelsY2.axisVisibility': 'y2AxisLineVisibility',
315
- 'gridLinesX.showMajorLines': 'showXMajorGridLines',
316
- 'gridLinesY.showMajorLines': 'showYMajorGridLines',
317
- 'gridLinesX.showMinorLines': 'showXMinorGridLines',
318
- 'gridLinesY.showMinorLines': 'showYMinorGridLines',
319
- 'gridLinesY2.showMajorLines': 'showY2MajorGridLines',
320
- 'gridLinesY2.showMinorLines': 'showY2MinorGridLines',
321
- 'axisX.scale': 'xAxisScale',
322
- 'axisY.scale': 'yAxisScale',
323
- 'axisY2.scale': 'y2AxisScale',
324
- 'axisX.maximumNumber': 'xAxisMax',
325
- 'axisY.maximumNumber': 'yAxisMax',
326
- 'axisY2.maximumNumber': 'y2AxisMax',
327
- 'axisX.minimumNumber': 'xAxisMin',
328
- 'axisY.minimumNumber': 'yAxisMin',
329
- 'axisY2.minimumNumber': 'y2AxisMin',
330
- 'axisX.includeZero': 'showXAxisWithZero',
331
- 'axisY.includeZero': 'showYAxisWithZero',
332
- 'axisY2.includeZero': 'showY2AxisWithZero',
333
- 'axisLabelsX.extendsAxisRange': 'showXAxisExtendedRange',
334
- 'axisLabelsY.extendsAxisRange': 'showYAxisExtendedRange',
335
- 'layout.splitSeries': 'showSplitSeries',
336
- 'layout.splitSeries.allowIndependentYRanges': 'showIndependentYRanges',
337
- 'axisY2.enabled': 'showOverlayY2Axis',
338
- 'axisY2.fields': 'y2Fields',
339
- 'chart.overlayFields': 'overlayFields',
340
- 'legend.labels': 'legendLabels',
341
- 'legend.labelStyle.overflowMode': 'legendTruncation',
342
- 'legend.mode': 'legendMode',
343
- 'legend.placement': 'legendDisplay',
344
- 'chart.nullValueMode': 'nullValueDisplay',
345
- 'chart.showDataLabels': 'dataValuesDisplay',
346
- fieldColors: 'seriesColorsByField',
347
- 'chart.resultTruncationLimit': 'resultLimit',
348
- 'chart.stackMode': 'stackMode',
349
- 'chart.barSpacing': 'barSpacing',
350
- 'chart.columnSpacing': 'columnSpacing',
351
- 'chart.seriesSpacing': 'seriesSpacing',
352
- 'chart.sliceCollapsingLabel': 'collapseLabel',
353
- 'chart.sliceCollapsingThreshold': 'collapseThreshold',
354
- hasDonutHole: 'showDonutHole',
247
+ "axisTitleX.text": "xAxisTitleText",
248
+ "axisTitleY.text": "yAxisTitleText",
249
+ "axisTitleY2.text": "y2AxisTitleText",
250
+ "axisTitleX.visibility": "xAxisTitleVisibility",
251
+ "axisTitleY.visibility": "yAxisTitleVisibility",
252
+ "axisTitleY2.visibility": "y2AxisTitleVisibility",
253
+ "axisLabelsX.majorLabelStyle.rotation": "xAxisLabelRotation",
254
+ "axisLabelsX.majorLabelVisibility": "xAxisLabelVisibility",
255
+ "axisLabelsY.majorLabelVisibility": "yAxisLabelVisibility",
256
+ "axisLabelsY2.majorLabelVisibility": "y2AxisLabelVisibility",
257
+ "axisLabelsX.majorTickVisibility": "xAxisMajorTickVisibility",
258
+ "axisLabelsY.majorTickVisibility": "yAxisMajorTickVisibility",
259
+ "axisLabelsY2.majorTickVisibility": "y2AxisMajorTickVisibility",
260
+ "axisLabelsX.minorTickVisibility": "xAxisMinorTickVisibility",
261
+ "axisLabelsY.minorTickVisibility": "yAxisMinorTickVisibility",
262
+ "axisLabelsY2.minorTickVisibility": "y2AxisMinorTickVisibility",
263
+ "axisLabelsX.majorTickSize": "xAxisMajorTickSize",
264
+ "axisLabelsY.majorTickSize": "yAxisMajorTickSize",
265
+ "axisLabelsY2.majorTickSize": "y2AxisMajorTickSize",
266
+ "axisLabelsX.minorTickSize": "xAxisMinorTickSize",
267
+ "axisLabelsY.minorTickSize": "yAxisMinorTickSize",
268
+ "axisLabelsY2.minorTickSize": "y2AxisMinorTickSize",
269
+ "axisLabelsX.majorUnit": "xAxisMajorTickInterval",
270
+ "axisLabelsY.majorUnit": "yAxisMajorTickInterval",
271
+ "axisLabelsY2.majorUnit": "y2AxisMajorTickInterval",
272
+ "axisX.abbreviation": "xAxisAbbreviation",
273
+ "axisY.abbreviation": "yAxisAbbreviation",
274
+ "axisY2.abbreviation": "y2AxisAbbreviation",
275
+ "axisLabelsX.integerUnits": "showRoundedXAxisLabels",
276
+ "axisLabelsY2.integerUnits": "showRoundedY2AxisLabels",
277
+ "axisLabelsX.maxLabelParts": "xAxisMaxLabelParts",
278
+ "axisLabelsX.axisVisibility": "xAxisLineVisibility",
279
+ "axisLabelsY.axisVisibility": "yAxisLineVisibility",
280
+ "axisLabelsY2.axisVisibility": "y2AxisLineVisibility",
281
+ "gridLinesX.showMajorLines": "showXMajorGridLines",
282
+ "gridLinesY.showMajorLines": "showYMajorGridLines",
283
+ "gridLinesX.showMinorLines": "showXMinorGridLines",
284
+ "gridLinesY.showMinorLines": "showYMinorGridLines",
285
+ "gridLinesY2.showMajorLines": "showY2MajorGridLines",
286
+ "gridLinesY2.showMinorLines": "showY2MinorGridLines",
287
+ "axisX.scale": "xAxisScale",
288
+ "axisY.scale": "yAxisScale",
289
+ "axisY2.scale": "y2AxisScale",
290
+ "axisX.maximumNumber": "xAxisMax",
291
+ "axisY.maximumNumber": "yAxisMax",
292
+ "axisY2.maximumNumber": "y2AxisMax",
293
+ "axisX.minimumNumber": "xAxisMin",
294
+ "axisY.minimumNumber": "yAxisMin",
295
+ "axisY2.minimumNumber": "y2AxisMin",
296
+ "axisX.includeZero": "showXAxisWithZero",
297
+ "axisY.includeZero": "showYAxisWithZero",
298
+ "axisY2.includeZero": "showY2AxisWithZero",
299
+ "axisLabelsX.extendsAxisRange": "showXAxisExtendedRange",
300
+ "axisLabelsY.extendsAxisRange": "showYAxisExtendedRange",
301
+ "layout.splitSeries": "showSplitSeries",
302
+ "layout.splitSeries.allowIndependentYRanges": "showIndependentYRanges",
303
+ "axisY2.enabled": "showOverlayY2Axis",
304
+ "axisY2.fields": "y2Fields",
305
+ "chart.overlayFields": "overlayFields",
306
+ "legend.labels": "legendLabels",
307
+ "legend.labelStyle.overflowMode": "legendTruncation",
308
+ "legend.mode": "legendMode",
309
+ "legend.placement": "legendDisplay",
310
+ "chart.nullValueMode": "nullValueDisplay",
311
+ "chart.showDataLabels": "dataValuesDisplay",
312
+ fieldColors: "seriesColorsByField",
313
+ "chart.resultTruncationLimit": "resultLimit",
314
+ "chart.stackMode": "stackMode",
315
+ "chart.barSpacing": "barSpacing",
316
+ "chart.columnSpacing": "columnSpacing",
317
+ "chart.seriesSpacing": "seriesSpacing",
318
+ "chart.sliceCollapsingLabel": "collapseLabel",
319
+ "chart.sliceCollapsingThreshold": "collapseThreshold",
320
+ hasDonutHole: "showDonutHole",
355
321
  // area specific mapped options
356
- areaFillOpacity: 'areaOpacity',
357
- 'chart.showLines': 'showLines',
322
+ areaFillOpacity: "areaOpacity",
323
+ "chart.showLines": "showLines",
358
324
  // bubble specific mapped options
359
- 'chart.bubbleMinimumSize': 'bubbleSizeMin',
360
- 'chart.bubbleMaximumSize': 'bubbleSizeMax',
361
- 'chart.bubbleSizeBy': 'bubbleSizeMethod',
325
+ "chart.bubbleMinimumSize": "bubbleSizeMin",
326
+ "chart.bubbleMaximumSize": "bubbleSizeMax",
327
+ "chart.bubbleSizeBy": "bubbleSizeMethod",
362
328
  // line specific mapped options
363
- fieldDashStyles: 'lineDashStylesByField',
364
- 'chart.showMarkers': 'markerDisplay',
329
+ fieldDashStyles: "lineDashStylesByField",
330
+ "chart.showMarkers": "markerDisplay",
365
331
  // scatter-specific options
366
- 'chart.markerSize': 'markerSize'
332
+ "chart.markerSize": "markerSize"
367
333
  };
368
334
  var visibilityEnumReplacements = {
369
- visible: 'show',
370
- collapsed: 'hide'
335
+ visible: "show",
336
+ collapsed: "hide"
371
337
  };
372
338
  var modeEnumReplacements = {
373
- none: 'off'
339
+ none: "off"
374
340
  };
375
341
  var abbreviationEnumReplacements = {
376
- none: 'auto'
342
+ none: "auto"
377
343
  };
378
- /**
379
- * for some options the valid values changed.
380
- * this maps enum values that need to be changed
381
- */
382
-
383
344
  var enumReplacements = {
384
345
  xAxisTitleVisibility: visibilityEnumReplacements,
385
346
  yAxisTitleVisibility: visibilityEnumReplacements,
@@ -390,127 +351,72 @@ var enumReplacements = {
390
351
  dataValuesDisplay: modeEnumReplacements,
391
352
  legendDisplay: modeEnumReplacements,
392
353
  legendTruncation: {
393
- ellipsisNone: 'ellipsisOff'
354
+ ellipsisNone: "ellipsisOff"
394
355
  },
395
356
  stackMode: {
396
- default: 'auto'
357
+ default: "auto"
397
358
  }
398
- }; // splits a string with multiple fields separated by comma
399
- // returns the same value if it's already an array
400
-
401
- var splitValue = function splitValue(oldValue) {
402
- return Array.isArray(oldValue) ? oldValue : oldValue.split(',');
403
- };
404
- /**
405
- * converts stringified objects into plain objects
406
- *
407
- * @param {string | Object} oldValue stringified object to parse
408
- * @returns {Object}
409
- */
410
-
411
-
412
- var parseObjects = function parseObjects(oldValue) {
413
- if (_typeof(oldValue) === 'object' && !Array.isArray(oldValue)) {
359
+ };
360
+ var splitValue = (oldValue) => Array.isArray(oldValue) ? oldValue : oldValue.split(",");
361
+ var parseObjects = (oldValue) => {
362
+ if (typeof oldValue === "object" && !Array.isArray(oldValue)) {
414
363
  return oldValue;
415
364
  }
416
-
417
- var nuValue = {};
418
-
365
+ let nuValue = {};
419
366
  try {
420
367
  nuValue = JSON.parse(oldValue);
421
368
  } catch (e) {
422
- /* noop */
423
369
  }
424
-
425
370
  return nuValue;
426
371
  };
427
- /**
428
- * some option values require special processing
429
- * (e.g. if the type of the updated option changed)
430
- * "legendLabels": "test,test2" => "legendLabels": ["test", "test2"]
431
- */
432
-
433
-
434
372
  var otherValueReplacements = {
435
373
  y2Fields: splitValue,
436
374
  overlayFields: splitValue,
437
375
  legendLabels: splitValue,
438
376
  seriesColorsByField: parseObjects,
439
377
  lineDashStylesByField: parseObjects,
440
-
441
378
  /**
442
379
  * the original markerDisplay was only exposed as `chart.showMarkers`
443
380
  * setting chart.showMarkers to true is the equivalent of `markerDisplay: 'outlined'`
444
381
  */
445
- markerDisplay: function markerDisplay(oldValue) {
446
- if (oldValue === false) return 'off';
447
- if (oldValue === true) return 'outlined';
382
+ markerDisplay: (oldValue) => {
383
+ if (oldValue === false) return "off";
384
+ if (oldValue === true) return "outlined";
448
385
  return oldValue;
449
386
  }
450
387
  };
451
- exports.otherValueReplacements = otherValueReplacements;
452
- /**
453
- * migrateChartingOptions
454
- * - renames option keys
455
- * - checks if enum values have changed for new options, replaces it
456
- * - checks if other replacements are necessary and applies them
457
- * @param {object} options dashboard-viz charting options
458
- * @returns {object} migratedOptions viz charting options
459
- */
460
-
461
- var migrateChartingOptions = function migrateChartingOptions(options) {
462
- var migratedOptions = {};
463
- Object.keys(options).forEach(function (key) {
388
+ var migrateChartingOptions = (options) => {
389
+ const migratedOptions = {};
390
+ Object.keys(options).forEach((key) => {
464
391
  var _a, _b, _c;
465
-
466
- var value = options[key];
467
- var updatedKey = (_a = optionRenames[key]) !== null && _a !== void 0 ? _a : key;
468
- var updatedValue = (_c = (_b = enumReplacements === null || enumReplacements === void 0 ? void 0 : enumReplacements[updatedKey]) === null || _b === void 0 ? void 0 : _b[value]) !== null && _c !== void 0 ? _c : value;
469
-
392
+ const value = options[key];
393
+ const updatedKey = (_a = optionRenames[key]) != null ? _a : key;
394
+ let updatedValue = (_c = (_b = enumReplacements == null ? void 0 : enumReplacements[updatedKey]) == null ? void 0 : _b[value]) != null ? _c : value;
470
395
  if (otherValueReplacements[updatedKey]) {
471
396
  updatedValue = otherValueReplacements[updatedKey](updatedValue);
472
397
  }
473
-
474
398
  migratedOptions[updatedKey] = updatedValue;
475
399
  });
476
400
  return migratedOptions;
477
401
  };
478
-
479
- exports.migrateChartingOptions = migrateChartingOptions;
480
- /**
481
- * helper that encapsulates shared migration logic across most charting-based viz
482
- * @param {Object} defaultChanges - map consisting of default value changes from viz.* to splunk.*
483
- * @param {Object} validOptions - the list of options that the new splunk.* viz supports
484
- * @param {VisualizationDefinition} vizDefinition - the viz definition to migrate
485
- * @param {String} vizType - the value of splunk.*
486
- */
487
-
488
- var migrateBaseChartingVizDefinition = function migrateBaseChartingVizDefinition(_ref) {
489
- var defaultChanges = _ref.defaultChanges,
490
- validOptions = _ref.validOptions,
491
- vizDefinition = _ref.vizDefinition,
492
- vizType = _ref.vizType;
493
-
494
- var _vizDefinition$encodi = vizDefinition.encoding,
495
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
496
- _vizDefinition$option = vizDefinition.options,
497
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
498
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
499
-
500
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
402
+ var migrateBaseChartingVizDefinition = ({
403
+ defaultChanges: defaultChanges10,
404
+ validOptions: validOptions22,
405
+ vizDefinition,
406
+ vizType
407
+ }) => {
408
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
409
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
501
410
  type: vizType,
502
411
  options: {},
503
412
  context: {}
504
- }); // translate encoding to dynamic options equivalent
505
-
506
- var _ref2 = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
507
- dataOptions = _ref2.options,
508
- dataContext = _ref2.context;
509
-
510
- var migratedOptions = Object.assign(Object.assign(Object.assign({}, defaultChanges), migrateChartingOptions(options)), dataOptions); // remove invalid options
511
-
512
- Object.keys(migratedOptions).forEach(function (key) {
513
- if (!validOptions[key]) {
413
+ });
414
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
415
+ encoding
416
+ );
417
+ const migratedOptions = __spreadValues(__spreadValues(__spreadValues({}, defaultChanges10), migrateChartingOptions(options)), dataOptions);
418
+ Object.keys(migratedOptions).forEach((key) => {
419
+ if (!validOptions22[key]) {
514
420
  delete migratedOptions[key];
515
421
  }
516
422
  });
@@ -519,1423 +425,361 @@ var migrateBaseChartingVizDefinition = function migrateBaseChartingVizDefinition
519
425
  return migratedDefinition;
520
426
  };
521
427
 
522
- exports.migrateBaseChartingVizDefinition = migrateBaseChartingVizDefinition;
523
-
524
- /***/ }),
525
- /* 4 */
526
- /***/ (function(module, exports, __webpack_require__) {
527
-
528
- "use strict";
428
+ // src/visualizations/area.ts
429
+ var defaultChanges = {
430
+ yAxisAbbreviation: "off",
431
+ y2AxisAbbreviation: "off",
432
+ showRoundedY2AxisLabels: false,
433
+ legendTruncation: "ellipsisMiddle",
434
+ showY2MajorGridLines: true
435
+ };
436
+ var migrateVizToSplunkArea = (vizDefinition) => migrateBaseChartingVizDefinition({
437
+ defaultChanges,
438
+ validOptions: visualization_schemas_exports.areaOptionsSchema,
439
+ vizDefinition,
440
+ vizType: "splunk.area"
441
+ });
529
442
 
443
+ // src/visualizations/bar.ts
444
+ var defaultChanges2 = {
445
+ yAxisAbbreviation: "off",
446
+ y2AxisAbbreviation: "off",
447
+ showRoundedY2AxisLabels: false,
448
+ legendTruncation: "ellipsisMiddle",
449
+ showY2MajorGridLines: true
450
+ };
451
+ var migrateVizToSplunkBar = (vizDefinition) => migrateBaseChartingVizDefinition({
452
+ defaultChanges: defaultChanges2,
453
+ validOptions: visualization_schemas_exports.barOptionsSchema,
454
+ vizDefinition,
455
+ vizType: "splunk.bar"
456
+ });
530
457
 
531
- Object.defineProperty(exports, "__esModule", {
532
- value: true
458
+ // src/visualizations/bubble.ts
459
+ var defaultChanges3 = {
460
+ yAxisAbbreviation: "off",
461
+ legendTruncation: "ellipsisMiddle"
462
+ };
463
+ var migrateVizToSplunkBubble = (vizDefinition) => migrateBaseChartingVizDefinition({
464
+ defaultChanges: defaultChanges3,
465
+ validOptions: visualization_schemas_exports.bubbleOptionsSchema,
466
+ vizDefinition,
467
+ vizType: "splunk.bubble"
533
468
  });
534
- exports.consolidateTrendDisplay = void 0;
535
- /**
536
- * Helper function to consolidate `trendDisplayMode` - percent/absolute
537
- * and `showTrendIndicator` - true/false into `trendDisplay` - off/percent/absolute for Single Value Variations
538
- * 1. if `showTrendIndicator` is explicitly false, `trendDisplay` is off
539
- * 2. if `showTrendIndicator` is undefined (defaults to true), return `trendDisplayMode` value if present
540
- * 3. if `showTrendIndicator` is explicitly true, return 'absolute'
541
- * 4. if both the old options are undefined, return nothing as their defaults (true and `absolute`)
542
- * correspond to `trendDisplay` default - absolute
543
- */
544
469
 
545
- var consolidateTrendDisplay = function consolidateTrendDisplay(trendDisplayMode, showTrendIndicator) {
546
- if (showTrendIndicator === false) {
547
- return 'off';
548
- }
470
+ // esm-externals:@splunk/visualization-encoding/utils/dsl
471
+ var dsl_exports = {};
472
+ __export(dsl_exports, {
473
+ default: () => dsl_default
474
+ });
475
+ var defaultImport3 = __toESM(require("@splunk/visualization-encoding/utils/dsl"));
476
+ __reExport(dsl_exports, require("@splunk/visualization-encoding/utils/dsl"));
477
+ var dsl_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
549
478
 
550
- if (['absolute', 'percent'].includes(trendDisplayMode)) {
551
- return trendDisplayMode;
479
+ // src/utils/migrationUtils.ts
480
+ var removeInvalidOptions = (currentOptions, validOptions22) => {
481
+ if (!currentOptions || !validOptions22) {
482
+ return;
552
483
  }
553
-
554
- if (showTrendIndicator === true) {
555
- return 'absolute';
484
+ const copiedCurrOptions = currentOptions;
485
+ Object.keys(copiedCurrOptions).forEach((key) => {
486
+ if (!(key in validOptions22)) {
487
+ delete copiedCurrOptions[key];
488
+ }
489
+ });
490
+ };
491
+ var renameVizOptions = (oldOptions, optionRenames9) => {
492
+ const updatedOptions = {};
493
+ if (!oldOptions) return {};
494
+ if (!optionRenames9) return oldOptions;
495
+ Object.entries(oldOptions).forEach(([oldOptName, val]) => {
496
+ var _a;
497
+ const optionName = (_a = optionRenames9[oldOptName]) != null ? _a : oldOptName;
498
+ updatedOptions[optionName] = val;
499
+ });
500
+ return updatedOptions;
501
+ };
502
+ var preserveDataSelectionForValueOption = (valueOption, selector) => {
503
+ if (valueOption) {
504
+ const dataSelectors = (0, dsl_exports.getDataSelectorsFromDSL)(valueOption);
505
+ const lastDataSelector = dataSelectors[dataSelectors.length - 1];
506
+ if (lastDataSelector.includes("seriesByIndex") || lastDataSelector.includes("seriesByName")) {
507
+ return `${valueOption} | ${selector}`;
508
+ }
556
509
  }
557
-
558
510
  return null;
559
511
  };
512
+ var addsDataSelectorToOptions = (dataOptions, selector) => {
513
+ const updatedDataOptions = {};
514
+ Object.keys(dataOptions).forEach((key) => {
515
+ const statement = dataOptions[key];
516
+ const updatedDSL = preserveDataSelectionForValueOption(statement, selector);
517
+ if (updatedDSL) {
518
+ updatedDataOptions[key] = updatedDSL;
519
+ } else {
520
+ updatedDataOptions[key] = statement;
521
+ }
522
+ });
523
+ return updatedDataOptions;
524
+ };
560
525
 
561
- exports.consolidateTrendDisplay = consolidateTrendDisplay;
562
-
563
- /***/ }),
564
- /* 5 */
565
- /***/ (function(module, exports) {
566
-
567
- module.exports = require("@babel/runtime/helpers/typeof");
568
-
569
- /***/ }),
570
- /* 6 */
571
- /***/ (function(module, exports) {
572
-
573
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
574
-
575
- /***/ }),
576
- /* 7 */
577
- /***/ (function(module, exports) {
578
-
579
- module.exports = require("@babel/runtime/helpers/slicedToArray");
580
-
581
- /***/ }),
582
- /* 8 */
583
- /***/ (function(module, exports, __webpack_require__) {
584
-
585
- "use strict";
586
-
526
+ // src/visualizations/choroplethSvg.ts
527
+ var optionRenames2 = {
528
+ featureId: "areaIds",
529
+ value: "areaValues",
530
+ fill: "areaColors"
531
+ };
532
+ var defaultOptionChanges = {
533
+ areaIds: "> primary | seriesByIndex(0)",
534
+ areaValues: "> primary | seriesByIndex(1)",
535
+ areaColors: "> primary | seriesByIndex(1) | gradient(fillGradientContext)"
536
+ };
537
+ var defaultContextChanges = {
538
+ fillGradientContext: {
539
+ colors: ["#7EEFDA", "#6484F6", "#C093F9", "#293873"]
540
+ }
541
+ };
542
+ var migrateVizToSplunkChoroplethSvg = (vizDefinition) => {
543
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
544
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
545
+ encoding
546
+ );
547
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
548
+ type: "splunk.choropleth.svg",
549
+ options: {},
550
+ context: {}
551
+ });
552
+ const migratedOptions = __spreadValues({}, options);
553
+ Object.keys(dataOptions).forEach((key) => {
554
+ var _a2;
555
+ const updatedKey = (_a2 = optionRenames2[key]) != null ? _a2 : key;
556
+ migratedOptions[updatedKey] = dataOptions[key];
557
+ });
558
+ migratedDefinition.options = __spreadValues(__spreadValues({}, defaultOptionChanges), migratedOptions);
559
+ migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges;
560
+ removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.choroplethSvgOptionsSchema);
561
+ return migratedDefinition;
562
+ };
587
563
 
588
- Object.defineProperty(exports, "__esModule", {
589
- value: true
564
+ // src/visualizations/column.ts
565
+ var defaultChanges4 = {
566
+ yAxisAbbreviation: "off",
567
+ y2AxisAbbreviation: "off",
568
+ showRoundedY2AxisLabels: false,
569
+ legendTruncation: "ellipsisMiddle",
570
+ showY2MajorGridLines: true
571
+ };
572
+ var migrateVizToSplunkColumn = (vizDefinition) => migrateBaseChartingVizDefinition({
573
+ defaultChanges: defaultChanges4,
574
+ validOptions: visualization_schemas_exports.columnOptionsSchema,
575
+ vizDefinition,
576
+ vizType: "splunk.column"
590
577
  });
591
- exports.consolidateDisplayOption = void 0;
592
- /**
593
- * Helper to convert old label and value options into consolidated labelDisplay and valueDisplay
594
- * If the `showOption` is explicitly false, then we return 'off'
595
- * If the `showOption` is undefined (which corresponds to a default of `true`), we return nothing to avoid conflating the viz definition (since this corresponds to `number` in the new display)
596
- * @param {Boolean} showOption - either one of `showLabel` or `showValue` in the old gauges
597
- * @param {Boolean} percentageOption - either one of `usePercentageRange` or `usePercentageValue` in the old gauges
598
- * @returns {String}
599
- */
600
578
 
601
- var consolidateDisplayOption = function consolidateDisplayOption(showOption, percentageOption) {
579
+ // src/visualizations/ellipse.ts
580
+ var optionsToRename = {
581
+ fill: "fillColor",
582
+ stroke: "strokeColor",
583
+ strokeDasharray: "strokeDashStyle"
584
+ };
585
+ var migrateVizToSplunkEllipse = (vizDefinition) => {
586
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
587
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
588
+ type: "splunk.ellipse",
589
+ options,
590
+ context: {}
591
+ });
592
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
593
+ encoding
594
+ );
595
+ const updatedDataOptions = addsDataSelectorToOptions(dataOptions, "lastPoint()");
596
+ migratedDefinition.options = __spreadValues(__spreadValues({}, options), updatedDataOptions);
597
+ migratedDefinition.options = renameVizOptions(migratedDefinition.options, optionsToRename);
598
+ removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.ellipseOptionsSchema);
599
+ migratedDefinition.context = dataContext;
600
+ return migratedDefinition;
601
+ };
602
+
603
+ // src/utils/gauges.ts
604
+ var consolidateDisplayOption = (showOption, percentageOption) => {
602
605
  if (showOption === false) {
603
- return 'off';
606
+ return "off";
604
607
  }
605
-
606
608
  if (percentageOption === true) {
607
- return 'percentage';
609
+ return "percentage";
608
610
  }
609
-
610
611
  if (showOption === true) {
611
- return 'number';
612
- } // if showOption is undefined and percentageOption is false, we don't need to return an explicit value (since 'number' is passed in implicitly)
613
-
614
-
612
+ return "number";
613
+ }
615
614
  return null;
616
615
  };
617
616
 
618
- exports.consolidateDisplayOption = consolidateDisplayOption;
619
-
620
- /***/ }),
621
- /* 9 */
622
- /***/ (function(module, exports) {
623
-
624
- module.exports = require("lodash");
625
-
626
- /***/ }),
627
- /* 10 */
628
- /***/ (function(module, exports, __webpack_require__) {
629
-
630
- "use strict";
631
-
632
-
633
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
634
- if (k2 === undefined) k2 = k;
635
- var desc = Object.getOwnPropertyDescriptor(m, k);
636
-
637
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
638
- desc = {
639
- enumerable: true,
640
- get: function get() {
641
- return m[k];
642
- }
617
+ // src/visualizations/fillergauge.ts
618
+ var optionRenames3 = {
619
+ majorUnit: "majorTickInterval"
620
+ };
621
+ var previousRangeValueConfig = [
622
+ { to: 10, value: "#5fbcff" },
623
+ { from: 10, to: 30, value: "#4beba8" },
624
+ { from: 30, to: 50, value: "#f4df7a" },
625
+ { from: 50, to: 70, value: "#fc9850" },
626
+ { from: 70, to: 100, value: "#ff7152" }
627
+ ];
628
+ var defaultChanges5 = {
629
+ gaugeColor: "> value | rangeValue(gaugeColorRangeValueContext)",
630
+ value: "> primary | seriesByIndex(0) | lastPoint()"
631
+ };
632
+ var migrateVizToSplunkFillerGauge = (vizDefinition) => {
633
+ var _b;
634
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
635
+ const migratedVisualization = __spreadProps(__spreadValues({
636
+ options
637
+ }, otherDefinitionParts), {
638
+ type: "splunk.fillergauge",
639
+ context: {}
640
+ });
641
+ const renamedOptions = renameVizOptions(options, optionRenames3);
642
+ const { options: encodingOptions, context: gaugeColorContext } = encodingToDynamicOptionsDSL(
643
+ encoding
644
+ );
645
+ const originalGaugeValue = encodingOptions.value;
646
+ if (typeof originalGaugeValue === "string") {
647
+ encodingOptions.value = (_b = preserveDataSelectionForValueOption(originalGaugeValue, "lastPoint()")) != null ? _b : originalGaugeValue;
648
+ }
649
+ if (encodingOptions == null ? void 0 : encodingOptions.gaugeColor) {
650
+ migratedVisualization.context = gaugeColorContext;
651
+ } else {
652
+ migratedVisualization.context = {
653
+ gaugeColorRangeValueContext: previousRangeValueConfig
643
654
  };
644
655
  }
656
+ const { showLabels, usePercentageRange, showValue, usePercentageValue } = options;
657
+ const labelDisplay = consolidateDisplayOption(showLabels, usePercentageRange);
658
+ const valueDisplay = consolidateDisplayOption(showValue, usePercentageValue);
659
+ migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultChanges5), renamedOptions), encodingOptions), typeof labelDisplay === "string" && { labelDisplay }), typeof valueDisplay === "string" && { valueDisplay });
660
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.fillerGaugeOptionsSchema);
661
+ return migratedVisualization;
662
+ };
645
663
 
646
- Object.defineProperty(o, k2, desc);
647
- } : function (o, m, k, k2) {
648
- if (k2 === undefined) k2 = k;
649
- o[k2] = m[k];
664
+ // src/visualizations/line.ts
665
+ var defaultChanges6 = {
666
+ yAxisAbbreviation: "off",
667
+ y2AxisAbbreviation: "off",
668
+ showRoundedY2AxisLabels: false,
669
+ legendTruncation: "ellipsisMiddle",
670
+ showY2MajorGridLines: true
671
+ };
672
+ var migrateVizToSplunkLine = (vizDefinition) => migrateBaseChartingVizDefinition({
673
+ defaultChanges: defaultChanges6,
674
+ validOptions: visualization_schemas_exports.lineOptionsSchema,
675
+ vizDefinition,
676
+ vizType: "splunk.line"
650
677
  });
651
678
 
652
- var __exportStar = this && this.__exportStar || function (m, exports) {
653
- for (var p in m) {
654
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
655
- }
679
+ // src/visualizations/image.ts
680
+ var migrateVizToSplunkImage = (vizDefinition) => {
681
+ const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
682
+ const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.image", context: {} });
683
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.imageOptionsSchema);
684
+ return migratedVisualization;
656
685
  };
657
686
 
658
- Object.defineProperty(exports, "__esModule", {
659
- value: true
660
- });
661
-
662
- __exportStar(__webpack_require__(11), exports);
687
+ // src/visualizations/markdown.ts
688
+ var migrateVizToSplunkMarkdown = (vizDefinition) => {
689
+ const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
690
+ const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.markdown", context: {} });
691
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.markdownOptionsSchema);
692
+ return migratedVisualization;
693
+ };
663
694
 
664
- /***/ }),
665
- /* 11 */
666
- /***/ (function(module, exports, __webpack_require__) {
667
-
668
- "use strict";
669
-
670
-
671
- Object.defineProperty(exports, "__esModule", {
672
- value: true
673
- });
674
- exports.inferToType = exports.canMigrate = exports.migrate = void 0;
675
-
676
- var visualizations_1 = __webpack_require__(12);
677
-
678
- var supportedMigrations = {
679
- 'viz.area': {
680
- 'splunk.area': visualizations_1.migrateVizToSplunkArea
681
- },
682
- 'viz.bar': {
683
- 'splunk.bar': visualizations_1.migrateVizToSplunkBar
684
- },
685
- 'viz.bubble': {
686
- 'splunk.bubble': visualizations_1.migrateVizToSplunkBubble
687
- },
688
- 'viz.column': {
689
- 'splunk.column': visualizations_1.migrateVizToSplunkColumn
690
- },
691
- 'viz.choropleth.svg': {
692
- 'splunk.choropleth.svg': visualizations_1.migrateVizToSplunkChoroplethSvg
693
- },
694
- 'viz.geojson.us': {
695
- 'splunk.map': visualizations_1.migrateVizToSplunkMapChoropleth
696
- },
697
- 'viz.geojson.world': {
698
- 'splunk.map': visualizations_1.migrateVizToSplunkMapChoropleth
699
- },
700
- 'viz.ellipse': {
701
- 'splunk.ellipse': visualizations_1.migrateVizToSplunkEllipse
702
- },
703
- 'viz.fillergauge': {
704
- 'splunk.fillergauge': visualizations_1.migrateVizToSplunkFillerGauge
705
- },
706
- 'viz.line': {
707
- 'splunk.line': visualizations_1.migrateVizToSplunkLine
708
- },
709
- 'viz.img': {
710
- 'splunk.image': visualizations_1.migrateVizToSplunkImage
711
- },
712
- 'viz.markdown': {
713
- 'splunk.markdown': visualizations_1.migrateVizToSplunkMarkdown
714
- },
715
- 'viz.markergauge': {
716
- 'splunk.markergauge': visualizations_1.migrateVizToSplunkMarkerGauge
717
- },
718
- 'viz.pie': {
719
- 'splunk.pie': visualizations_1.migrateVizToSplunkPie
720
- },
721
- 'viz.rectangle': {
722
- 'splunk.rectangle': visualizations_1.migrateVizToSplunkRectangle
723
- },
724
- 'viz.singlevalue': {
725
- 'splunk.singlevalue': visualizations_1.migrateVizToSplunkSingleValue
726
- },
727
- 'viz.singlevalueicon': {
728
- 'splunk.singlevalueicon': visualizations_1.migrateVizToSplunkSingleValueIcon
729
- },
730
- 'viz.singlevalueradial': {
731
- 'splunk.singlevalueradial': visualizations_1.migrateVizToSplunkSingleValueRadial
732
- },
733
- 'viz.scatter': {
734
- 'splunk.scatter': visualizations_1.migrateVizToSplunkScatter
735
- },
736
- 'viz.table': {
737
- 'splunk.table': visualizations_1.migrateVizToSplunkTable
738
- },
739
- 'viz.text': {
740
- 'splunk.markdown': visualizations_1.migrateVizTextToSplunkMarkdown
741
- },
742
- 'viz.punchcard': {
743
- 'splunk.punchcard': visualizations_1.migrateVizToSplunkPunchcard
744
- }
745
- };
746
-
747
- var inferToType = function inferToType(typeFromDefinition) {
748
- if (typeFromDefinition === 'viz.img') {
749
- return 'splunk.image';
750
- }
751
-
752
- if (typeFromDefinition === 'viz.text') {
753
- return 'splunk.markdown';
754
- }
755
-
756
- if (typeFromDefinition === 'viz.geojson.us' || typeFromDefinition === 'viz.geojson.world') {
757
- return 'splunk.map';
758
- }
759
-
760
- return typeFromDefinition.replace(/^viz\./, 'splunk.');
761
- };
762
-
763
- exports.inferToType = inferToType;
764
-
765
- var migrate = function migrate(_ref) {
766
- var definition = _ref.definition,
767
- toTypeFromParams = _ref.toType;
768
-
769
- var _a;
770
-
771
- var toType = toTypeFromParams !== null && toTypeFromParams !== void 0 ? toTypeFromParams : inferToType(definition.type);
772
-
773
- if (!((_a = supportedMigrations === null || supportedMigrations === void 0 ? void 0 : supportedMigrations[definition === null || definition === void 0 ? void 0 : definition.type]) === null || _a === void 0 ? void 0 : _a[toType])) {
774
- throw new Error('Migration currently not supported');
775
- }
776
-
777
- return supportedMigrations[definition.type][toType](definition);
778
- };
779
-
780
- exports.migrate = migrate;
781
-
782
- var canMigrate = function canMigrate(_ref2) {
783
- var fromType = _ref2.fromType,
784
- toType = _ref2.toType;
785
-
786
- var _a;
787
-
788
- if ((_a = supportedMigrations === null || supportedMigrations === void 0 ? void 0 : supportedMigrations[fromType]) === null || _a === void 0 ? void 0 : _a[toType]) {
789
- return true;
790
- }
791
-
792
- return false;
793
- };
794
-
795
- exports.canMigrate = canMigrate;
796
-
797
- /***/ }),
798
- /* 12 */
799
- /***/ (function(module, exports, __webpack_require__) {
800
-
801
- "use strict";
802
-
803
-
804
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
805
- if (k2 === undefined) k2 = k;
806
- var desc = Object.getOwnPropertyDescriptor(m, k);
807
-
808
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
809
- desc = {
810
- enumerable: true,
811
- get: function get() {
812
- return m[k];
813
- }
814
- };
815
- }
816
-
817
- Object.defineProperty(o, k2, desc);
818
- } : function (o, m, k, k2) {
819
- if (k2 === undefined) k2 = k;
820
- o[k2] = m[k];
821
- });
822
-
823
- var __exportStar = this && this.__exportStar || function (m, exports) {
824
- for (var p in m) {
825
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
826
- }
827
- };
828
-
829
- Object.defineProperty(exports, "__esModule", {
830
- value: true
831
- });
832
-
833
- __exportStar(__webpack_require__(13), exports);
834
-
835
- __exportStar(__webpack_require__(16), exports);
836
-
837
- __exportStar(__webpack_require__(17), exports);
838
-
839
- __exportStar(__webpack_require__(18), exports);
840
-
841
- __exportStar(__webpack_require__(20), exports);
842
-
843
- __exportStar(__webpack_require__(21), exports);
844
-
845
- __exportStar(__webpack_require__(22), exports);
846
-
847
- __exportStar(__webpack_require__(23), exports);
848
-
849
- __exportStar(__webpack_require__(24), exports);
850
-
851
- __exportStar(__webpack_require__(25), exports);
852
-
853
- __exportStar(__webpack_require__(26), exports);
854
-
855
- __exportStar(__webpack_require__(27), exports);
856
-
857
- __exportStar(__webpack_require__(28), exports);
858
-
859
- __exportStar(__webpack_require__(29), exports);
860
-
861
- __exportStar(__webpack_require__(30), exports);
862
-
863
- __exportStar(__webpack_require__(31), exports);
864
-
865
- __exportStar(__webpack_require__(32), exports);
866
-
867
- __exportStar(__webpack_require__(33), exports);
868
-
869
- __exportStar(__webpack_require__(35), exports);
870
-
871
- __exportStar(__webpack_require__(36), exports);
872
-
873
- __exportStar(__webpack_require__(37), exports);
874
-
875
- /***/ }),
876
- /* 13 */
877
- /***/ (function(module, exports, __webpack_require__) {
878
-
879
- "use strict";
880
-
881
-
882
- Object.defineProperty(exports, "__esModule", {
883
- value: true
884
- });
885
- exports.migrateVizToSplunkArea = void 0;
886
-
887
- var visualization_schemas_1 = __webpack_require__(0);
888
-
889
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
890
-
891
-
892
- var defaultChanges = {
893
- yAxisAbbreviation: 'off',
894
- y2AxisAbbreviation: 'off',
895
- showRoundedY2AxisLabels: false,
896
- legendTruncation: 'ellipsisMiddle',
897
- showY2MajorGridLines: true
898
- };
899
-
900
- var migrateVizToSplunkArea = function migrateVizToSplunkArea(vizDefinition) {
901
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
902
- defaultChanges: defaultChanges,
903
- validOptions: visualization_schemas_1.areaOptionsSchema,
904
- vizDefinition: vizDefinition,
905
- vizType: 'splunk.area'
906
- });
907
- };
908
-
909
- exports.migrateVizToSplunkArea = migrateVizToSplunkArea;
910
-
911
- /***/ }),
912
- /* 14 */
913
- /***/ (function(module, exports, __webpack_require__) {
914
-
915
- "use strict";
916
-
917
-
918
- var _typeof = __webpack_require__(5);
919
-
920
- var _toConsumableArray = __webpack_require__(6);
921
-
922
- Object.defineProperty(exports, "__esModule", {
923
- value: true
924
- });
925
- exports.encodingToDynamicOptionsDSL = void 0;
926
-
927
- var Base_1 = __webpack_require__(15); // @TODO(pwied): move the parsing helpers so we can deprecate visualization-encoding-parsers package
928
- // index based references are defined by <dataSource>[<index>]
929
- // this regex matches <text with numbers>[<anything>]
930
- // the "[" "]" part makes it an index based reference
931
-
932
-
933
- var indexBasedRegx = /^[A-Za-z0-9_]+\[.*\].*$/; // name based references are defined by <dataSource>.<columnName>
934
- // the "." access makes it a name based reference
935
-
936
- var nameBasedRegx = /^[A-Za-z0-9_]+\..*$/;
937
-
938
- var isIndexBasedReference = function isIndexBasedReference(ref) {
939
- return indexBasedRegx.test(ref);
940
- };
941
-
942
- var isNameBasedReference = function isNameBasedReference(ref) {
943
- return nameBasedRegx.test(ref);
944
- };
945
-
946
- var convertFormatterToDSL = function convertFormatterToDSL(fieldReference, key, translatedValue) {
947
- var _a, _b, _c, _d, _e, _f;
948
-
949
- switch ((_a = fieldReference === null || fieldReference === void 0 ? void 0 : fieldReference.format) === null || _a === void 0 ? void 0 : _a.type) {
950
- case 'gradient':
951
- return {
952
- contextConfig: Object.assign(Object.assign({}, Array.isArray((_b = fieldReference.format) === null || _b === void 0 ? void 0 : _b.ranges) && {
953
- stops: _toConsumableArray(fieldReference.format.ranges)
954
- }), Array.isArray((_c = fieldReference.format) === null || _c === void 0 ? void 0 : _c.values) && {
955
- colors: _toConsumableArray(fieldReference.format.values)
956
- }),
957
- contextKey: "".concat(key, "GradientContext"),
958
- dsl: "".concat(translatedValue, " | gradient(").concat(key, "GradientContext)")
959
- };
960
-
961
- case 'rangevalue':
962
- {
963
- var contextKey = "".concat(key, "RangeValueContext");
964
- return {
965
- contextConfig: ((_d = fieldReference.format) === null || _d === void 0 ? void 0 : _d.ranges) || [],
966
- contextKey: contextKey,
967
- dsl: "".concat(translatedValue, " | rangeValue(").concat(contextKey, ")")
968
- };
969
- }
970
-
971
- case 'matchvalue':
972
- {
973
- var defaultValue = (_e = fieldReference.format) === null || _e === void 0 ? void 0 : _e.defaultValue;
974
- var matchValueContextKey = "".concat(key, "MatchValueContext");
975
- return {
976
- contextConfig: ((_f = fieldReference.format) === null || _f === void 0 ? void 0 : _f.matches) || [],
977
- contextKey: matchValueContextKey,
978
- dsl: "".concat(translatedValue, " | matchValue(").concat(matchValueContextKey).concat(defaultValue !== null && defaultValue !== undefined ? ", ".concat(typeof defaultValue === 'string' ? "\"".concat(defaultValue, "\"") : defaultValue) : '', ")")
979
- };
980
- }
981
-
982
- default:
983
- break;
984
- }
985
-
986
- return null;
987
- };
988
- /**
989
- * Translates encoding data selections in array format
990
- *
991
- * Note:
992
- * 'frameBySeriesIndexes' only supports positive indexes
993
- *
994
- * Examples:
995
- * 1. all index based selection
996
- * ['primary[0]', 'primary[1]'] => '> primary | frameBySeriesIndexes(0,1)'
997
- *
998
- * 2. all name based selection
999
- * ['primary.foo', 'primary.bar'] => '> primary | frameBySeriesNames("foo","bar")'
1000
- *
1001
- * 3. index or name based selections
1002
- * ['primary.foo', 'primary[1]'] => '> primary | frameBySeriesNamesOrIndexes("foo",1)'
1003
- */
1004
-
1005
-
1006
- var translateArrayFormatDataReference = function translateArrayFormatDataReference(encodingDataReference) {
1007
- if (encodingDataReference.length === 0) {
1008
- return null;
1009
- }
1010
-
1011
- var allIndexBased = encodingDataReference.every(isIndexBasedReference);
1012
- var allNameBased = encodingDataReference.every(isNameBasedReference);
1013
-
1014
- if (allIndexBased) {
1015
- var _ref = (0, Base_1.parseIndexBasedFieldReference)(encodingDataReference[0]),
1016
- _dataSourceName = _ref.dataSourceName;
1017
-
1018
- var indexesStr = encodingDataReference.map(function (ref) {
1019
- var _a;
1020
-
1021
- return (_a = (0, Base_1.parseIndexBasedFieldReference)(ref)) === null || _a === void 0 ? void 0 : _a.fieldIndex;
1022
- }).join(',');
1023
- return "> ".concat(_dataSourceName, " | frameBySeriesIndexes(").concat(indexesStr, ")");
1024
- }
1025
-
1026
- if (allNameBased) {
1027
- var _ref2 = (0, Base_1.parseNameBasedFieldReference)(encodingDataReference[0]),
1028
- _dataSourceName2 = _ref2.dataSourceName;
1029
-
1030
- var namesStr = encodingDataReference.map(function (ref) {
1031
- var _a;
1032
-
1033
- return "\"".concat((_a = (0, Base_1.parseNameBasedFieldReference)(ref)) === null || _a === void 0 ? void 0 : _a.fieldName, "\"");
1034
- }).join(',');
1035
- return "> ".concat(_dataSourceName2, " | frameBySeriesNames(").concat(namesStr, ")");
1036
- } // it's a mix of name and index based references
1037
- // get the first ref to extract the dataSource
1038
-
1039
-
1040
- var firstEntry = encodingDataReference[0];
1041
-
1042
- var _ref3 = isIndexBasedReference(firstEntry) ? (0, Base_1.parseIndexBasedFieldReference)(firstEntry) : (0, Base_1.parseNameBasedFieldReference)(firstEntry),
1043
- dataSourceName = _ref3.dataSourceName;
1044
-
1045
- var paramStr = encodingDataReference.map(function (ref) {
1046
- var _a, _b;
1047
-
1048
- return isIndexBasedReference(ref) ? (_a = (0, Base_1.parseIndexBasedFieldReference)(ref)) === null || _a === void 0 ? void 0 : _a.fieldIndex : "\"".concat((_b = (0, Base_1.parseNameBasedFieldReference)(ref)) === null || _b === void 0 ? void 0 : _b.fieldName, "\"");
1049
- }).join(',');
1050
- return "> ".concat(dataSourceName, " | frameBySeriesNamesOrIndexes(").concat(paramStr, ")");
1051
- };
1052
- /**
1053
- * Translates an encoding data selection string to a dynamic options data selection
1054
- *
1055
- * Index based column selection
1056
- * 'primary[0]' => '> primary | seriesByIndex(0)'
1057
- *
1058
- * Index range based column selection
1059
- * 'primary[1:]' => '> primary | frameBySeriesIndexRange(1)'
1060
- * 'primary[0:3]' => '> primary | frameBySeriesIndexRange(0,2)'
1061
- *
1062
- * Name based column selection
1063
- * 'primary.foo' => '> primary | seriesByName("foo")'
1064
- *
1065
- * Encoding references
1066
- * 'encoding.x' => '> x'
1067
- */
1068
-
1069
-
1070
- var translateDataReference = function translateDataReference(encodingDataReference) {
1071
- if (encodingDataReference.indexOf('encoding.') === 0) {
1072
- return "> ".concat(encodingDataReference.replace('encoding.', ''));
1073
- }
1074
-
1075
- var isIndexBasedRef = isIndexBasedReference(encodingDataReference);
1076
- var isNameBasedRef = isNameBasedReference(encodingDataReference);
1077
-
1078
- if (!isIndexBasedRef && !isNameBasedRef) {
1079
- console.warn('Unable to parse the encoding. Please verify the encoding format is correct');
1080
- return null;
1081
- }
1082
-
1083
- if (isNameBasedRef) {
1084
- var _ref4 = (0, Base_1.parseNameBasedFieldReference)(encodingDataReference),
1085
- dataSourceName = _ref4.dataSourceName,
1086
- fieldName = _ref4.fieldName,
1087
- columnIndex = _ref4.columnIndex;
1088
-
1089
- var returnString = "> ".concat(dataSourceName, " | seriesByName(\"").concat(fieldName, "\")");
1090
-
1091
- if (columnIndex) {
1092
- returnString += " | pointByIndex(".concat(columnIndex, ")");
1093
- }
1094
-
1095
- return returnString;
1096
- }
1097
-
1098
- if (isIndexBasedRef) {
1099
- var _ref5 = (0, Base_1.parseIndexBasedFieldReference)(encodingDataReference),
1100
- _dataSourceName3 = _ref5.dataSourceName,
1101
- fieldIndex = _ref5.fieldIndex,
1102
- _columnIndex = _ref5.columnIndex,
1103
- isFieldIndexRange = _ref5.isFieldIndexRange,
1104
- fromFieldIndex = _ref5.fromFieldIndex,
1105
- toFieldIndex = _ref5.toFieldIndex;
1106
-
1107
- if (isFieldIndexRange) {
1108
- var dslToIndexString;
1109
-
1110
- if (toFieldIndex === -1) {
1111
- dslToIndexString = '';
1112
- } else {
1113
- // adjust index, DSL is using default slice behavior whereas encoding behaved differently
1114
- dslToIndexString = ",".concat(toFieldIndex + 1);
1115
- }
1116
-
1117
- return "> ".concat(_dataSourceName3, " | frameBySeriesIndexRange(").concat(fromFieldIndex).concat(dslToIndexString, ")");
1118
- }
1119
-
1120
- var _returnString = "> ".concat(_dataSourceName3, " | seriesByIndex(").concat(fieldIndex, ")");
1121
-
1122
- if (_columnIndex) {
1123
- _returnString += " | pointByIndex(".concat(_columnIndex, ")");
1124
- }
1125
-
1126
- return _returnString;
1127
- }
1128
-
1129
- return null;
1130
- };
1131
- /**
1132
- * An encoding configuration can come in various different forms:
1133
- *
1134
- * 1. Simple data selection (either index or name based)
1135
- * {
1136
- * x: 'primary[0]',
1137
- * y: 'primary.count'
1138
- * }
1139
- *
1140
- * 2. Multi column selection in array format
1141
- * {
1142
- * x: 'primary[0]',
1143
- * y: ['primary.count', 'primary.count2']
1144
- * }
1145
- *
1146
- * 3. Advanced Encoding Configuration (for data selection and formatting)
1147
- * {
1148
- * x: {
1149
- * field: 'primary[0]',
1150
- * },
1151
- * y: {
1152
- * field: 'primary[1]',
1153
- * format: {},
1154
- * }
1155
- * }
1156
- */
1157
-
1158
-
1159
- var encodingToDynamicOptionsDSL = function encodingToDynamicOptionsDSL(encoding) {
1160
- var dynamicOptions = {
1161
- options: {},
1162
- context: {}
1163
- };
1164
- var translatedOptions = {};
1165
- var encodingObj = encoding !== null && encoding !== void 0 ? encoding : {};
1166
- Object.keys(encodingObj).forEach(function (key) {
1167
- var fieldReference = encoding[key];
1168
- var fieldReferenceStr = fieldReference;
1169
-
1170
- if (_typeof(fieldReference) === 'object' && !Array.isArray(fieldReference)) {
1171
- var field = fieldReference.field;
1172
-
1173
- if (field && !Array.isArray(field)) {
1174
- fieldReferenceStr = field;
1175
- }
1176
- }
1177
-
1178
- var translatedValue; // field reference is either in form of array or string
1179
-
1180
- if (Array.isArray(fieldReference)) {
1181
- translatedValue = translateArrayFormatDataReference(fieldReference);
1182
- } else {
1183
- translatedValue = translateDataReference(fieldReferenceStr);
1184
- } // omit if translated value is not set
1185
-
1186
-
1187
- if (translatedValue) {
1188
- translatedOptions[key] = translatedValue;
1189
- var convertedFormatterObject = convertFormatterToDSL(fieldReference, key, translatedValue);
1190
-
1191
- if (convertedFormatterObject) {
1192
- translatedOptions[key] = convertedFormatterObject.dsl;
1193
- dynamicOptions.context[convertedFormatterObject.contextKey] = convertedFormatterObject.contextConfig;
1194
- }
1195
- }
1196
- });
1197
- dynamicOptions.options = translatedOptions;
1198
- return dynamicOptions;
1199
- };
1200
-
1201
- exports.encodingToDynamicOptionsDSL = encodingToDynamicOptionsDSL;
1202
-
1203
- /***/ }),
1204
- /* 15 */
1205
- /***/ (function(module, exports) {
1206
-
1207
- module.exports = require("@splunk/visualization-encoding-parsers/Base");
1208
-
1209
- /***/ }),
1210
- /* 16 */
1211
- /***/ (function(module, exports, __webpack_require__) {
1212
-
1213
- "use strict";
1214
-
1215
-
1216
- Object.defineProperty(exports, "__esModule", {
1217
- value: true
1218
- });
1219
- exports.migrateVizToSplunkBar = void 0;
1220
-
1221
- var visualization_schemas_1 = __webpack_require__(0);
1222
-
1223
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
1224
-
1225
-
1226
- var defaultChanges = {
1227
- yAxisAbbreviation: 'off',
1228
- y2AxisAbbreviation: 'off',
1229
- showRoundedY2AxisLabels: false,
1230
- legendTruncation: 'ellipsisMiddle',
1231
- showY2MajorGridLines: true
1232
- };
1233
-
1234
- var migrateVizToSplunkBar = function migrateVizToSplunkBar(vizDefinition) {
1235
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
1236
- defaultChanges: defaultChanges,
1237
- validOptions: visualization_schemas_1.barOptionsSchema,
1238
- vizDefinition: vizDefinition,
1239
- vizType: 'splunk.bar'
1240
- });
1241
- };
1242
-
1243
- exports.migrateVizToSplunkBar = migrateVizToSplunkBar;
1244
-
1245
- /***/ }),
1246
- /* 17 */
1247
- /***/ (function(module, exports, __webpack_require__) {
1248
-
1249
- "use strict";
1250
-
1251
-
1252
- Object.defineProperty(exports, "__esModule", {
1253
- value: true
1254
- });
1255
- exports.migrateVizToSplunkBubble = void 0;
1256
-
1257
- var visualization_schemas_1 = __webpack_require__(0);
1258
-
1259
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
1260
-
1261
-
1262
- var defaultChanges = {
1263
- yAxisAbbreviation: 'off',
1264
- legendTruncation: 'ellipsisMiddle'
1265
- };
1266
-
1267
- var migrateVizToSplunkBubble = function migrateVizToSplunkBubble(vizDefinition) {
1268
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
1269
- defaultChanges: defaultChanges,
1270
- validOptions: visualization_schemas_1.bubbleOptionsSchema,
1271
- vizDefinition: vizDefinition,
1272
- vizType: 'splunk.bubble'
1273
- });
1274
- };
1275
-
1276
- exports.migrateVizToSplunkBubble = migrateVizToSplunkBubble;
1277
-
1278
- /***/ }),
1279
- /* 18 */
1280
- /***/ (function(module, exports, __webpack_require__) {
1281
-
1282
- "use strict";
1283
-
1284
-
1285
- var __rest = this && this.__rest || function (s, e) {
1286
- var t = {};
1287
-
1288
- for (var p in s) {
1289
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1290
- }
1291
-
1292
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1293
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1294
- }
1295
- return t;
1296
- };
1297
-
1298
- Object.defineProperty(exports, "__esModule", {
1299
- value: true
1300
- });
1301
- exports.migrateVizToSplunkChoroplethSvg = void 0;
1302
-
1303
- var visualization_schemas_1 = __webpack_require__(0);
1304
-
1305
- var encoding_1 = __webpack_require__(2);
1306
-
1307
- var migrationUtils_1 = __webpack_require__(1);
1308
-
1309
- var optionRenames = {
1310
- featureId: 'areaIds',
1311
- value: 'areaValues',
1312
- fill: 'areaColors'
1313
- }; // old default encoding configurations should be retained in migrated configuration
1314
-
1315
- var defaultOptionChanges = {
1316
- areaIds: '> primary | seriesByIndex(0)',
1317
- areaValues: '> primary | seriesByIndex(1)',
1318
- areaColors: '> primary | seriesByIndex(1) | gradient(fillGradientContext)'
1319
- };
1320
- var defaultContextChanges = {
1321
- fillGradientContext: {
1322
- colors: ['#7EEFDA', '#6484F6', '#C093F9', '#293873']
1323
- }
1324
- };
1325
-
1326
- var migrateVizToSplunkChoroplethSvg = function migrateVizToSplunkChoroplethSvg(vizDefinition) {
1327
- var _vizDefinition$encodi = vizDefinition.encoding,
1328
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
1329
- _vizDefinition$option = vizDefinition.options,
1330
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1331
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]); // translate encoding to dynamic options equivalent
1332
-
1333
-
1334
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
1335
- dataOptions = _ref.options,
1336
- dataContext = _ref.context;
1337
-
1338
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
1339
- type: 'splunk.choropleth.svg',
1340
- options: {},
1341
- context: {}
1342
- }); // add migrated option names and values
1343
-
1344
- var migratedOptions = Object.assign({}, options);
1345
- Object.keys(dataOptions).forEach(function (key) {
1346
- var _a;
1347
-
1348
- var updatedKey = (_a = optionRenames[key]) !== null && _a !== void 0 ? _a : key;
1349
- migratedOptions[updatedKey] = dataOptions[key];
1350
- }); // update migrated options and context
1351
-
1352
- migratedDefinition.options = Object.assign(Object.assign({}, defaultOptionChanges), migratedOptions);
1353
- migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges; // remove invalid options
1354
-
1355
- (0, migrationUtils_1.removeInvalidOptions)(migratedDefinition.options, visualization_schemas_1.choroplethSvgOptionsSchema);
1356
- return migratedDefinition;
1357
- };
1358
-
1359
- exports.migrateVizToSplunkChoroplethSvg = migrateVizToSplunkChoroplethSvg;
1360
-
1361
- /***/ }),
1362
- /* 19 */
1363
- /***/ (function(module, exports) {
1364
-
1365
- module.exports = require("@splunk/visualization-encoding/utils/dsl");
1366
-
1367
- /***/ }),
1368
- /* 20 */
1369
- /***/ (function(module, exports, __webpack_require__) {
1370
-
1371
- "use strict";
1372
-
1373
-
1374
- Object.defineProperty(exports, "__esModule", {
1375
- value: true
1376
- });
1377
- exports.migrateVizToSplunkColumn = void 0;
1378
-
1379
- var visualization_schemas_1 = __webpack_require__(0);
1380
-
1381
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
1382
-
1383
-
1384
- var defaultChanges = {
1385
- yAxisAbbreviation: 'off',
1386
- y2AxisAbbreviation: 'off',
1387
- showRoundedY2AxisLabels: false,
1388
- legendTruncation: 'ellipsisMiddle',
1389
- showY2MajorGridLines: true
1390
- };
1391
-
1392
- var migrateVizToSplunkColumn = function migrateVizToSplunkColumn(vizDefinition) {
1393
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
1394
- defaultChanges: defaultChanges,
1395
- validOptions: visualization_schemas_1.columnOptionsSchema,
1396
- vizDefinition: vizDefinition,
1397
- vizType: 'splunk.column'
1398
- });
1399
- };
1400
-
1401
- exports.migrateVizToSplunkColumn = migrateVizToSplunkColumn;
1402
-
1403
- /***/ }),
1404
- /* 21 */
1405
- /***/ (function(module, exports, __webpack_require__) {
1406
-
1407
- "use strict";
1408
-
1409
-
1410
- var __rest = this && this.__rest || function (s, e) {
1411
- var t = {};
1412
-
1413
- for (var p in s) {
1414
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1415
- }
1416
-
1417
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1418
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1419
- }
1420
- return t;
1421
- };
1422
-
1423
- Object.defineProperty(exports, "__esModule", {
1424
- value: true
1425
- });
1426
- exports.migrateVizToSplunkEllipse = void 0;
1427
-
1428
- var visualization_schemas_1 = __webpack_require__(0);
1429
-
1430
- var encoding_1 = __webpack_require__(2);
1431
-
1432
- var migrationUtils_1 = __webpack_require__(1);
1433
-
1434
- var optionsToRename = {
1435
- fill: 'fillColor',
1436
- stroke: 'strokeColor',
1437
- strokeDasharray: 'strokeDashStyle'
1438
- };
1439
-
1440
- var migrateVizToSplunkEllipse = function migrateVizToSplunkEllipse(vizDefinition) {
1441
- var _vizDefinition$encodi = vizDefinition.encoding,
1442
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
1443
- _vizDefinition$option = vizDefinition.options,
1444
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1445
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
1446
-
1447
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
1448
- type: 'splunk.ellipse',
1449
- options: options,
1450
- context: {}
1451
- });
1452
-
1453
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
1454
- dataOptions = _ref.options,
1455
- dataContext = _ref.context; // To simulate the implicit logic in the shape parser that Ellipse utilizes, append
1456
- // the lastPoint() DataSeries selector.
1457
-
1458
-
1459
- var updatedDataOptions = (0, migrationUtils_1.addsDataSelectorToOptions)(dataOptions, 'lastPoint()');
1460
- migratedDefinition.options = Object.assign(Object.assign({}, options), updatedDataOptions); // perform any option renaming
1461
-
1462
- migratedDefinition.options = (0, migrationUtils_1.renameVizOptions)(migratedDefinition.options, optionsToRename); // remove invalid options from new definition
1463
-
1464
- (0, migrationUtils_1.removeInvalidOptions)(migratedDefinition.options, visualization_schemas_1.ellipseOptionsSchema);
1465
- migratedDefinition.context = dataContext;
1466
- return migratedDefinition;
1467
- };
1468
-
1469
- exports.migrateVizToSplunkEllipse = migrateVizToSplunkEllipse;
1470
-
1471
- /***/ }),
1472
- /* 22 */
1473
- /***/ (function(module, exports, __webpack_require__) {
1474
-
1475
- "use strict";
1476
-
1477
-
1478
- var __rest = this && this.__rest || function (s, e) {
1479
- var t = {};
1480
-
1481
- for (var p in s) {
1482
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1483
- }
1484
-
1485
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1486
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1487
- }
1488
- return t;
1489
- };
1490
-
1491
- Object.defineProperty(exports, "__esModule", {
1492
- value: true
1493
- });
1494
- exports.migrateVizToSplunkFillerGauge = void 0;
1495
-
1496
- var visualization_schemas_1 = __webpack_require__(0);
1497
-
1498
- var encoding_1 = __webpack_require__(2);
1499
-
1500
- var gauges_1 = __webpack_require__(8);
1501
-
1502
- var migrationUtils_1 = __webpack_require__(1);
1503
-
1504
- var optionRenames = {
1505
- majorUnit: 'majorTickInterval'
1506
- };
1507
- var previousRangeValueConfig = [{
1508
- to: 10,
1509
- value: '#5fbcff'
1510
- }, {
1511
- from: 10,
1512
- to: 30,
1513
- value: '#4beba8'
1514
- }, {
1515
- from: 30,
1516
- to: 50,
1517
- value: '#f4df7a'
1518
- }, {
1519
- from: 50,
1520
- to: 70,
1521
- value: '#fc9850'
1522
- }, {
1523
- from: 70,
1524
- to: 100,
1525
- value: '#ff7152'
1526
- }];
1527
- var defaultChanges = {
1528
- gaugeColor: '> value | rangeValue(gaugeColorRangeValueContext)',
1529
- value: '> primary | seriesByIndex(0) | lastPoint()'
1530
- };
1531
-
1532
- var migrateVizToSplunkFillerGauge = function migrateVizToSplunkFillerGauge(vizDefinition) {
1533
- var _a;
1534
-
1535
- var _vizDefinition$option = vizDefinition.options,
1536
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1537
- _vizDefinition$encodi = vizDefinition.encoding,
1538
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
1539
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
1540
-
1541
- var migratedVisualization = Object.assign(Object.assign({
1542
- options: options
1543
- }, otherDefinitionParts), {
1544
- type: 'splunk.fillergauge',
1545
- context: {}
1546
- });
1547
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
1548
-
1549
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
1550
- encodingOptions = _ref.options,
1551
- gaugeColorContext = _ref.context; // if a viz.fillergauge receives an entire column for `value` (e.g. primary[0]), it will select the last value of the column
1552
- // this contrasts with viz.markergauge (which takes the first point of the column)
1553
- // this is due to differing behavior in the FillerGaugeParser, which explicitly retrieves the last point in a received array
1554
- // https://cd.splunkdev.com/devplat/vision/-/blob/main/packages/visualization-encoding-parsers/src/FillerGaugeParser.js#L79
1555
-
1556
-
1557
- var originalGaugeValue = encodingOptions.value;
1558
-
1559
- if (typeof originalGaugeValue === 'string') {
1560
- encodingOptions.value = (_a = (0, migrationUtils_1.preserveDataSelectionForValueOption)(originalGaugeValue, 'lastPoint()')) !== null && _a !== void 0 ? _a : originalGaugeValue;
1561
- }
1562
-
1563
- if (encodingOptions === null || encodingOptions === void 0 ? void 0 : encodingOptions.gaugeColor) {
1564
- migratedVisualization.context = gaugeColorContext;
1565
- } else {
1566
- // preserve the default context if no gaugeColor encoding was configured
1567
- migratedVisualization.context = {
1568
- gaugeColorRangeValueContext: previousRangeValueConfig
1569
- };
1570
- }
1571
-
1572
- var showLabels = options.showLabels,
1573
- usePercentageRange = options.usePercentageRange,
1574
- showValue = options.showValue,
1575
- usePercentageValue = options.usePercentageValue;
1576
- var labelDisplay = (0, gauges_1.consolidateDisplayOption)(showLabels, usePercentageRange);
1577
- var valueDisplay = (0, gauges_1.consolidateDisplayOption)(showValue, usePercentageValue);
1578
- migratedVisualization.options = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultChanges), renamedOptions), encodingOptions), typeof labelDisplay === 'string' && {
1579
- labelDisplay: labelDisplay
1580
- }), typeof valueDisplay === 'string' && {
1581
- valueDisplay: valueDisplay
1582
- }); // remove invalid options using the optionsSchema for splunk.fillergauge as reference
1583
-
1584
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.fillerGaugeOptionsSchema);
1585
- return migratedVisualization;
1586
- };
1587
-
1588
- exports.migrateVizToSplunkFillerGauge = migrateVizToSplunkFillerGauge;
1589
-
1590
- /***/ }),
1591
- /* 23 */
1592
- /***/ (function(module, exports, __webpack_require__) {
1593
-
1594
- "use strict";
1595
-
1596
-
1597
- Object.defineProperty(exports, "__esModule", {
1598
- value: true
1599
- });
1600
- exports.migrateVizToSplunkLine = void 0;
1601
-
1602
- var visualization_schemas_1 = __webpack_require__(0);
1603
-
1604
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
1605
- // except for markerDisplay which migrates to the new default 'off'
1606
-
1607
-
1608
- var defaultChanges = {
1609
- yAxisAbbreviation: 'off',
1610
- y2AxisAbbreviation: 'off',
1611
- showRoundedY2AxisLabels: false,
1612
- legendTruncation: 'ellipsisMiddle',
1613
- showY2MajorGridLines: true
1614
- };
1615
-
1616
- var migrateVizToSplunkLine = function migrateVizToSplunkLine(vizDefinition) {
1617
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
1618
- defaultChanges: defaultChanges,
1619
- validOptions: visualization_schemas_1.lineOptionsSchema,
1620
- vizDefinition: vizDefinition,
1621
- vizType: 'splunk.line'
1622
- });
1623
- };
1624
-
1625
- exports.migrateVizToSplunkLine = migrateVizToSplunkLine;
1626
-
1627
- /***/ }),
1628
- /* 24 */
1629
- /***/ (function(module, exports, __webpack_require__) {
1630
-
1631
- "use strict";
1632
-
1633
-
1634
- var __rest = this && this.__rest || function (s, e) {
1635
- var t = {};
1636
-
1637
- for (var p in s) {
1638
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1639
- }
1640
-
1641
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1642
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1643
- }
1644
- return t;
1645
- };
1646
-
1647
- Object.defineProperty(exports, "__esModule", {
1648
- value: true
1649
- });
1650
- exports.migrateVizToSplunkImage = void 0;
1651
-
1652
- var visualization_schemas_1 = __webpack_require__(0);
1653
-
1654
- var migrationUtils_1 = __webpack_require__(1);
1655
-
1656
- var migrateVizToSplunkImage = function migrateVizToSplunkImage(vizDefinition) {
1657
- var _vizDefinition$option = vizDefinition.options,
1658
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1659
- otherDefinitionParts = __rest(vizDefinition, ["options"]);
1660
-
1661
- var migratedVisualization = Object.assign(Object.assign({
1662
- options: options
1663
- }, otherDefinitionParts), {
1664
- type: 'splunk.image',
1665
- context: {}
1666
- }); // remove invalid options using the optionsSchema for splunk.image as reference
1667
-
1668
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.imageOptionsSchema);
1669
- return migratedVisualization;
1670
- };
1671
-
1672
- exports.migrateVizToSplunkImage = migrateVizToSplunkImage;
1673
-
1674
- /***/ }),
1675
- /* 25 */
1676
- /***/ (function(module, exports, __webpack_require__) {
1677
-
1678
- "use strict";
1679
-
1680
-
1681
- var __rest = this && this.__rest || function (s, e) {
1682
- var t = {};
1683
-
1684
- for (var p in s) {
1685
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1686
- }
1687
-
1688
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1689
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1690
- }
1691
- return t;
1692
- };
1693
-
1694
- Object.defineProperty(exports, "__esModule", {
1695
- value: true
1696
- });
1697
- exports.migrateVizToSplunkMarkdown = void 0;
1698
-
1699
- var visualization_schemas_1 = __webpack_require__(0);
1700
-
1701
- var migrationUtils_1 = __webpack_require__(1);
1702
-
1703
- var migrateVizToSplunkMarkdown = function migrateVizToSplunkMarkdown(vizDefinition) {
1704
- var _vizDefinition$option = vizDefinition.options,
1705
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1706
- otherDefinitionParts = __rest(vizDefinition, ["options"]);
1707
-
1708
- var migratedVisualization = Object.assign(Object.assign({
1709
- options: options
1710
- }, otherDefinitionParts), {
1711
- type: 'splunk.markdown',
1712
- context: {}
1713
- }); // remove invalid options using the optionsSchema for splunk.markdown as reference
1714
-
1715
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.markdownOptionsSchema);
1716
- return migratedVisualization;
1717
- };
1718
-
1719
- exports.migrateVizToSplunkMarkdown = migrateVizToSplunkMarkdown;
1720
-
1721
- /***/ }),
1722
- /* 26 */
1723
- /***/ (function(module, exports, __webpack_require__) {
1724
-
1725
- "use strict";
1726
-
1727
-
1728
- var __rest = this && this.__rest || function (s, e) {
1729
- var t = {};
1730
-
1731
- for (var p in s) {
1732
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1733
- }
1734
-
1735
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1736
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1737
- }
1738
- return t;
1739
- };
1740
-
1741
- Object.defineProperty(exports, "__esModule", {
1742
- value: true
1743
- });
1744
- exports.migrateVizToSplunkMarkerGauge = void 0;
1745
-
1746
- var visualization_schemas_1 = __webpack_require__(0);
1747
-
1748
- var encoding_1 = __webpack_require__(2);
1749
-
1750
- var migrationUtils_1 = __webpack_require__(1);
1751
-
1752
- var gauges_1 = __webpack_require__(8); // old default configurations should be retained in migrated configuration
1753
-
1754
-
1755
- var defaultChanges = {
1756
- gaugeRanges: [{
1757
- from: 90,
1758
- to: 100,
1759
- value: '#CB3B43'
1760
- }, {
1761
- from: 50,
1762
- to: 90,
1763
- value: '#F4DF7A'
1764
- }, {
1765
- from: 0,
1766
- to: 50,
1767
- value: '#4BEBA8'
1768
- }],
1769
- value: '> primary | seriesByIndex(0) | lastPoint()'
1770
- };
1771
- var optionRenames = {
1772
- majorUnit: 'majorTickInterval',
1773
- ranges: 'gaugeRanges'
1774
- };
1775
-
1776
- var migrateVizToSplunkMarkerGauge = function migrateVizToSplunkMarkerGauge(vizDefinition) {
1777
- var _a;
1778
-
1779
- var _vizDefinition$option = vizDefinition.options,
1780
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1781
- _vizDefinition$encodi = vizDefinition.encoding,
1782
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
1783
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
1784
-
1785
- var migratedVisualization = Object.assign(Object.assign({
1786
- options: options
695
+ // src/visualizations/markergauge.ts
696
+ var defaultChanges7 = {
697
+ gaugeRanges: [
698
+ { from: 90, to: 100, value: "#CB3B43" },
699
+ { from: 50, to: 90, value: "#F4DF7A" },
700
+ { from: 0, to: 50, value: "#4BEBA8" }
701
+ ],
702
+ value: "> primary | seriesByIndex(0) | lastPoint()"
703
+ };
704
+ var optionRenames4 = {
705
+ majorUnit: "majorTickInterval",
706
+ ranges: "gaugeRanges"
707
+ };
708
+ var migrateVizToSplunkMarkerGauge = (vizDefinition) => {
709
+ var _b;
710
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
711
+ const migratedVisualization = __spreadProps(__spreadValues({
712
+ options
1787
713
  }, otherDefinitionParts), {
1788
- type: 'splunk.markergauge',
714
+ type: "splunk.markergauge",
1789
715
  context: {}
1790
716
  });
1791
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
1792
-
1793
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
1794
- dataOptions = _ref.options; // viz.markergauge has behavior where if a column without a specific point (e.g. primary[1]) is selected,
1795
- // the markerGauge will only display the first point of the column
1796
- // the following logic accounts for this and appends firstPoint() to the DSL statement
1797
-
1798
-
1799
- var originalGaugeValue = dataOptions.value;
1800
-
1801
- if (typeof originalGaugeValue === 'string') {
1802
- dataOptions.value = (_a = (0, migrationUtils_1.preserveDataSelectionForValueOption)(originalGaugeValue, 'firstPoint()')) !== null && _a !== void 0 ? _a : originalGaugeValue;
1803
- }
1804
-
1805
- var showLabels = renamedOptions.showLabels,
1806
- usePercentageRange = renamedOptions.usePercentageRange,
1807
- showValue = renamedOptions.showValue,
1808
- usePercentageValue = renamedOptions.usePercentageValue;
1809
- var labelDisplay = (0, gauges_1.consolidateDisplayOption)(showLabels, usePercentageRange);
1810
- var valueDisplay = (0, gauges_1.consolidateDisplayOption)(showValue, usePercentageValue);
1811
- migratedVisualization.options = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultChanges), renamedOptions), dataOptions), typeof labelDisplay === 'string' && {
1812
- labelDisplay: labelDisplay
1813
- }), typeof valueDisplay === 'string' && {
1814
- valueDisplay: valueDisplay
1815
- }); // remove invalid options using the optionsSchema for splunk.markergauge as reference
1816
-
1817
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.markerGaugeOptionsSchema);
717
+ const renamedOptions = renameVizOptions(options, optionRenames4);
718
+ const { options: dataOptions } = encodingToDynamicOptionsDSL(encoding);
719
+ const originalGaugeValue = dataOptions.value;
720
+ if (typeof originalGaugeValue === "string") {
721
+ dataOptions.value = (_b = preserveDataSelectionForValueOption(originalGaugeValue, "firstPoint()")) != null ? _b : originalGaugeValue;
722
+ }
723
+ const { showLabels, usePercentageRange, showValue, usePercentageValue } = renamedOptions;
724
+ const labelDisplay = consolidateDisplayOption(showLabels, usePercentageRange);
725
+ const valueDisplay = consolidateDisplayOption(showValue, usePercentageValue);
726
+ migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultChanges7), renamedOptions), dataOptions), typeof labelDisplay === "string" && { labelDisplay }), typeof valueDisplay === "string" && { valueDisplay });
727
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.markerGaugeOptionsSchema);
1818
728
  return migratedVisualization;
1819
729
  };
1820
730
 
1821
- exports.migrateVizToSplunkMarkerGauge = migrateVizToSplunkMarkerGauge;
1822
-
1823
- /***/ }),
1824
- /* 27 */
1825
- /***/ (function(module, exports, __webpack_require__) {
1826
-
1827
- "use strict";
1828
-
1829
-
1830
- var __rest = this && this.__rest || function (s, e) {
1831
- var t = {};
1832
-
1833
- for (var p in s) {
1834
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
731
+ // src/visualizations/pie.ts
732
+ var migratePieChartLabelAndPercent = (options) => {
733
+ if (!("chart.showLabels" in options) && !("chart.showPercent" in options)) {
734
+ return {};
1835
735
  }
1836
-
1837
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1838
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
736
+ if (!("chart.showLabels" in options) && "chart.showPercent" in options) {
737
+ return { labelDisplay: options["chart.showPercent"] ? "valuesAndPercentage" : "values" };
1839
738
  }
1840
- return t;
1841
- };
1842
-
1843
- Object.defineProperty(exports, "__esModule", {
1844
- value: true
1845
- });
1846
- exports.migrateVizToSplunkPie = void 0;
1847
-
1848
- var visualization_schemas_1 = __webpack_require__(0);
1849
-
1850
- var encoding_1 = __webpack_require__(2);
1851
-
1852
- var splunk_charting_1 = __webpack_require__(3);
1853
-
1854
- var migratePieChartLabelAndPercent = function migratePieChartLabelAndPercent(options) {
1855
- // if neither chart.showLabels or chart.showPercent is specified in viz.pie,
1856
- // splunk.pie use the default labelDisplay value
1857
- if (!('chart.showLabels' in options) && !('chart.showPercent' in options)) {
1858
- return {};
1859
- } // if only chart.showPercent is specified in viz.pie
1860
-
1861
-
1862
- if (!('chart.showLabels' in options) && 'chart.showPercent' in options) {
1863
- return {
1864
- labelDisplay: options['chart.showPercent'] ? 'valuesAndPercentage' : 'values'
1865
- };
1866
- } // if only chart.showLabels is specified in viz.pie
1867
-
1868
-
1869
- if ('chart.showLabels' in options && !('chart.showPercent' in options)) {
1870
- return {
1871
- labelDisplay: options['chart.showLabels'] ? 'values' : 'off'
1872
- };
1873
- } // if both chart.showLabels and chart.showPercent are specified in viz.pie
1874
-
1875
-
1876
- var labelOption = {
1877
- labelDisplay: 'values'
739
+ if ("chart.showLabels" in options && !("chart.showPercent" in options)) {
740
+ return { labelDisplay: options["chart.showLabels"] ? "values" : "off" };
741
+ }
742
+ const labelOption = {
743
+ labelDisplay: "values"
1878
744
  };
1879
-
1880
- if (options['chart.showLabels'] && options['chart.showPercent']) {
1881
- labelOption.labelDisplay = 'valuesAndPercentage';
745
+ if (options["chart.showLabels"] && options["chart.showPercent"]) {
746
+ labelOption.labelDisplay = "valuesAndPercentage";
1882
747
  }
1883
-
1884
- if (!options['chart.showLabels']) {
1885
- labelOption.labelDisplay = 'off';
748
+ if (!options["chart.showLabels"]) {
749
+ labelOption.labelDisplay = "off";
1886
750
  }
1887
-
1888
751
  return labelOption;
1889
- }; // retain the pie position when converting viz.pie to splunk.pie - SCP-48658
1890
-
1891
-
1892
- var migrateDonutChart = function migrateDonutChart(options) {
752
+ };
753
+ var migrateDonutChart = (options) => {
1893
754
  if (options.hasDonutHole) {
1894
- if (options['legend.placement'] === 'none') {
1895
- return {
1896
- labelDisplay: 'off'
1897
- };
755
+ if (options["legend.placement"] === "none") {
756
+ return { labelDisplay: "off" };
1898
757
  }
1899
-
1900
- return {
1901
- labelDisplay: 'values'
1902
- };
758
+ return { labelDisplay: "values" };
1903
759
  }
1904
-
1905
760
  return {};
1906
761
  };
1907
-
1908
- var migrateFieldColors = function migrateFieldColors(options) {
1909
- if ('fieldColors' in options) {
762
+ var migrateFieldColors = (options) => {
763
+ if ("fieldColors" in options) {
1910
764
  return {
1911
- seriesColorsByField: splunk_charting_1.otherValueReplacements.seriesColorsByField(options.fieldColors)
765
+ seriesColorsByField: otherValueReplacements.seriesColorsByField(options.fieldColors)
1912
766
  };
1913
767
  }
1914
-
1915
768
  return {};
1916
769
  };
1917
-
1918
- var migrateVizToSplunkPie = function migrateVizToSplunkPie(vizDefinition) {
1919
- var _vizDefinition$encodi = vizDefinition.encoding,
1920
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
1921
- _vizDefinition$option = vizDefinition.options,
1922
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
1923
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
1924
-
1925
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
1926
- type: 'splunk.pie',
770
+ var migrateVizToSplunkPie = (vizDefinition) => {
771
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
772
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
773
+ type: "splunk.pie",
1927
774
  options: {},
1928
775
  context: {}
1929
- }); // translate encoding to dynamic options equivalent
1930
-
1931
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
1932
- dataOptions = _ref.options,
1933
- dataContext = _ref.context;
1934
-
1935
- var migratedOptions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, migratePieChartLabelAndPercent(options)), (0, splunk_charting_1.migrateChartingOptions)(options)), migrateFieldColors(options)), migrateDonutChart(options)), dataOptions); // remove invalid options
1936
-
1937
- Object.keys(migratedOptions).forEach(function (key) {
1938
- if (!visualization_schemas_1.pieOptionsSchema[key]) {
776
+ });
777
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
778
+ encoding
779
+ );
780
+ const migratedOptions = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, migratePieChartLabelAndPercent(options)), migrateChartingOptions(options)), migrateFieldColors(options)), migrateDonutChart(options)), dataOptions);
781
+ Object.keys(migratedOptions).forEach((key) => {
782
+ if (!visualization_schemas_exports.pieOptionsSchema[key]) {
1939
783
  delete migratedOptions[key];
1940
784
  }
1941
785
  });
@@ -1944,1120 +788,709 @@ var migrateVizToSplunkPie = function migrateVizToSplunkPie(vizDefinition) {
1944
788
  return migratedDefinition;
1945
789
  };
1946
790
 
1947
- exports.migrateVizToSplunkPie = migrateVizToSplunkPie;
1948
-
1949
- /***/ }),
1950
- /* 28 */
1951
- /***/ (function(module, exports, __webpack_require__) {
1952
-
1953
- "use strict";
1954
-
1955
-
1956
- Object.defineProperty(exports, "__esModule", {
1957
- value: true
1958
- });
1959
- exports.migrateVizToSplunkScatter = void 0;
1960
-
1961
- var visualization_schemas_1 = __webpack_require__(0);
1962
-
1963
- var splunk_charting_1 = __webpack_require__(3); // old default configurations should be retained in migrated configuration
1964
-
1965
-
1966
- var defaultChanges = {
1967
- yAxisAbbreviation: 'off',
1968
- legendTruncation: 'ellipsisMiddle'
1969
- };
1970
-
1971
- var migrateVizToSplunkScatter = function migrateVizToSplunkScatter(vizDefinition) {
1972
- return (0, splunk_charting_1.migrateBaseChartingVizDefinition)({
1973
- defaultChanges: defaultChanges,
1974
- validOptions: visualization_schemas_1.scatterOptionsSchema,
1975
- vizDefinition: vizDefinition,
1976
- vizType: 'splunk.scatter'
1977
- });
1978
- };
1979
-
1980
- exports.migrateVizToSplunkScatter = migrateVizToSplunkScatter;
1981
-
1982
- /***/ }),
1983
- /* 29 */
1984
- /***/ (function(module, exports, __webpack_require__) {
1985
-
1986
- "use strict";
1987
-
1988
-
1989
- var __rest = this && this.__rest || function (s, e) {
1990
- var t = {};
1991
-
1992
- for (var p in s) {
1993
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1994
- }
1995
-
1996
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1997
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1998
- }
1999
- return t;
791
+ // src/visualizations/scatter.ts
792
+ var defaultChanges8 = {
793
+ yAxisAbbreviation: "off",
794
+ legendTruncation: "ellipsisMiddle"
2000
795
  };
2001
-
2002
- Object.defineProperty(exports, "__esModule", {
2003
- value: true
796
+ var migrateVizToSplunkScatter = (vizDefinition) => migrateBaseChartingVizDefinition({
797
+ defaultChanges: defaultChanges8,
798
+ validOptions: visualization_schemas_exports.scatterOptionsSchema,
799
+ vizDefinition,
800
+ vizType: "splunk.scatter"
2004
801
  });
2005
- exports.migrateVizToSplunkRectangle = void 0;
2006
-
2007
- var visualization_schemas_1 = __webpack_require__(0);
2008
-
2009
- var encoding_1 = __webpack_require__(2);
2010
802
 
2011
- var migrationUtils_1 = __webpack_require__(1);
2012
-
2013
- var optionsToRename = {
2014
- fill: 'fillColor',
2015
- stroke: 'strokeColor',
2016
- strokeDasharray: 'strokeDashStyle',
2017
- strokeLinejoin: 'strokeJoinStyle'
2018
- };
2019
-
2020
- var migrateVizToSplunkRectangle = function migrateVizToSplunkRectangle(vizDefinition) {
2021
- var _vizDefinition$encodi = vizDefinition.encoding,
2022
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2023
- options = vizDefinition.options,
2024
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
2025
-
2026
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
2027
- type: 'splunk.rectangle',
803
+ // src/visualizations/rectangle.ts
804
+ var optionsToRename2 = {
805
+ fill: "fillColor",
806
+ stroke: "strokeColor",
807
+ strokeDasharray: "strokeDashStyle",
808
+ strokeLinejoin: "strokeJoinStyle"
809
+ };
810
+ var migrateVizToSplunkRectangle = (vizDefinition) => {
811
+ const _a = vizDefinition, { encoding = {}, options } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
812
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
813
+ type: "splunk.rectangle",
2028
814
  options: {},
2029
815
  context: {}
2030
- }); // translate encoding to dynamic options equivalent
2031
-
2032
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2033
- dataOptions = _ref.options,
2034
- dataContext = _ref.context; // To simulate the implicit logic in the shape parser that Rectangle utilizes, append
2035
- // the lastPoint() DataSeries selector.
2036
-
2037
-
2038
- var updatedDataOptions = (0, migrationUtils_1.addsDataSelectorToOptions)(dataOptions, 'lastPoint()');
2039
- migratedDefinition.options = Object.assign(Object.assign({}, options), updatedDataOptions); // perform option rename
2040
-
2041
- migratedDefinition.options = (0, migrationUtils_1.renameVizOptions)(migratedDefinition.options, optionsToRename); // remove invalid options, validOptions is taken from the config.optionsSchema
2042
-
2043
- (0, migrationUtils_1.removeInvalidOptions)(migratedDefinition.options, visualization_schemas_1.rectangleOptionsSchema);
816
+ });
817
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
818
+ encoding
819
+ );
820
+ const updatedDataOptions = addsDataSelectorToOptions(dataOptions, "lastPoint()");
821
+ migratedDefinition.options = __spreadValues(__spreadValues({}, options), updatedDataOptions);
822
+ migratedDefinition.options = renameVizOptions(migratedDefinition.options, optionsToRename2);
823
+ removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.rectangleOptionsSchema);
2044
824
  migratedDefinition.context = dataContext;
2045
825
  return migratedDefinition;
2046
826
  };
2047
827
 
2048
- exports.migrateVizToSplunkRectangle = migrateVizToSplunkRectangle;
2049
-
2050
- /***/ }),
2051
- /* 30 */
2052
- /***/ (function(module, exports, __webpack_require__) {
2053
-
2054
- "use strict";
2055
-
2056
-
2057
- var __rest = this && this.__rest || function (s, e) {
2058
- var t = {};
2059
-
2060
- for (var p in s) {
2061
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
828
+ // src/utils/singlevalue.ts
829
+ var consolidateTrendDisplay = (trendDisplayMode, showTrendIndicator) => {
830
+ if (showTrendIndicator === false) {
831
+ return "off";
2062
832
  }
2063
-
2064
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2065
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
833
+ if (["absolute", "percent"].includes(trendDisplayMode)) {
834
+ return trendDisplayMode;
835
+ }
836
+ if (showTrendIndicator === true) {
837
+ return "absolute";
2066
838
  }
2067
- return t;
839
+ return null;
2068
840
  };
2069
841
 
2070
- Object.defineProperty(exports, "__esModule", {
2071
- value: true
2072
- });
2073
- exports.migrateVizToSplunkSingleValue = void 0;
2074
-
2075
- var visualization_schemas_1 = __webpack_require__(0);
2076
-
2077
- var encoding_1 = __webpack_require__(2);
2078
-
2079
- var migrationUtils_1 = __webpack_require__(1);
2080
-
2081
- var singlevalue_1 = __webpack_require__(4); // old default configurations should be retained in migrated configuration
2082
-
2083
-
842
+ // src/visualizations/singlevalue.ts
2084
843
  var defaultsToRetain = {
2085
844
  showSparklineAreaGraph: false,
2086
845
  sparklineValues: '> primary | seriesByTypes("number", "string")'
2087
846
  };
2088
- var optionRenames = {
2089
- useTrendUnits: 'shouldAbbreviateTrendValue',
2090
- useThousandSeparators: 'shouldUseThousandSeparators',
2091
- sparklineAreaGraph: 'showSparklineAreaGraph',
2092
- sparklineFillColor: 'sparklineAreaColor',
2093
- sparklineAcceptNullData: 'shouldSparklineAcceptNullData',
2094
- deltaFontSize: 'trendFontSize'
2095
- };
2096
- /**
2097
- * Helper function to consolidate `sparklinePosition` - before/after/below
2098
- * and `showSparkline` - true/false into `sparklineDisplay` - off/before/after/below
2099
- * 1. if `showSparkline` is explicitly false, `sparklineDisplay` is off
2100
- * 2. if `showSparkline` is undefined (defaults to true), return `sparklinePosition` value if present
2101
- * 3. if `showSparkline` is explicitly true, return 'below'
2102
- * 4. if both the old options are undefined, return nothing as their defaults (true and `below`)
2103
- * correspond to `sparklineDisplay` default - below
2104
- */
2105
-
2106
- var consolidateSparklineDisplay = function consolidateSparklineDisplay(sparklinePosition, showSparkline) {
847
+ var optionRenames5 = {
848
+ useTrendUnits: "shouldAbbreviateTrendValue",
849
+ useThousandSeparators: "shouldUseThousandSeparators",
850
+ sparklineAreaGraph: "showSparklineAreaGraph",
851
+ sparklineFillColor: "sparklineAreaColor",
852
+ sparklineAcceptNullData: "shouldSparklineAcceptNullData",
853
+ deltaFontSize: "trendFontSize"
854
+ };
855
+ var consolidateSparklineDisplay = (sparklinePosition, showSparkline) => {
2107
856
  if (showSparkline === false) {
2108
- return 'off';
857
+ return "off";
2109
858
  }
2110
-
2111
- if (['before', 'after', 'below'].includes(sparklinePosition)) {
859
+ if (["before", "after", "below"].includes(sparklinePosition)) {
2112
860
  return sparklinePosition;
2113
861
  }
2114
-
2115
862
  if (showSparkline === true) {
2116
- return 'below';
863
+ return "below";
2117
864
  }
2118
-
2119
865
  return null;
2120
866
  };
2121
-
2122
- var migrateVizToSplunkSingleValue = function migrateVizToSplunkSingleValue(vizDefinition) {
2123
- var _a, _b, _c;
2124
-
2125
- var _vizDefinition$option = vizDefinition.options,
2126
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2127
- _vizDefinition$encodi = vizDefinition.encoding,
2128
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2129
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
2130
-
2131
- var migratedVisualization = Object.assign(Object.assign({}, otherDefinitionParts), {
2132
- type: 'splunk.singlevalue',
2133
- context: {},
2134
- options: {}
2135
- });
2136
-
2137
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2138
- dataOptions = _ref.options,
2139
- dataContext = _ref.context;
2140
-
2141
- var migratedDataOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.trend) && {
2142
- sparklineValues: dataOptions.trend
2143
- }), (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.majorColor) && {
2144
- majorColor: (_a = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.majorColor, 'lastPoint()')) !== null && _a !== void 0 ? _a : dataOptions.majorColor
2145
- }), (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.deltaColor) && {
2146
- trendColor: (_b = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.deltaColor, 'lastPoint()')) !== null && _b !== void 0 ? _b : dataOptions.deltaColor
2147
- }), (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.fill) && {
2148
- backgroundColor: (_c = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.fill, 'lastPoint()')) !== null && _c !== void 0 ? _c : dataOptions.fill
2149
- });
2150
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
2151
- var trendDisplayMode = renamedOptions.trendDisplayMode,
2152
- showTrendIndicator = renamedOptions.showTrendIndicator,
2153
- showSparkline = renamedOptions.showSparkline,
2154
- sparklinePosition = renamedOptions.sparklinePosition;
2155
- var trendDisplay = (0, singlevalue_1.consolidateTrendDisplay)(trendDisplayMode, showTrendIndicator);
2156
- var sparklineDisplay = consolidateSparklineDisplay(sparklinePosition, showSparkline);
2157
- migratedVisualization.options = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, defaultsToRetain), renamedOptions), migratedDataOptions), typeof trendDisplay === 'string' && {
2158
- trendDisplay: trendDisplay
2159
- }), typeof sparklineDisplay === 'string' && {
2160
- sparklineDisplay: sparklineDisplay
2161
- });
2162
- migratedVisualization.context = dataContext; // remove invalid (and deprecated) options using the optionsSchema for splunk.singlevalue as reference
2163
-
2164
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.singleValueOptionsSchema);
2165
- return migratedVisualization;
2166
- };
2167
-
2168
- exports.migrateVizToSplunkSingleValue = migrateVizToSplunkSingleValue;
2169
-
2170
- /***/ }),
2171
- /* 31 */
2172
- /***/ (function(module, exports, __webpack_require__) {
2173
-
2174
- "use strict";
2175
-
2176
-
2177
- var __rest = this && this.__rest || function (s, e) {
2178
- var t = {};
2179
-
2180
- for (var p in s) {
2181
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2182
- }
2183
-
2184
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2185
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2186
- }
2187
- return t;
2188
- };
2189
-
2190
- Object.defineProperty(exports, "__esModule", {
2191
- value: true
2192
- });
2193
- exports.migrateVizToSplunkSingleValueIcon = void 0;
2194
-
2195
- var visualization_schemas_1 = __webpack_require__(0);
2196
-
2197
- var encoding_1 = __webpack_require__(2);
2198
-
2199
- var migrationUtils_1 = __webpack_require__(1);
2200
-
2201
- var singlevalue_1 = __webpack_require__(4);
2202
-
2203
- var defaultsToRetain = {
2204
- majorValue: '> primary | seriesByIndex(0) | lastPoint()',
2205
- trendValue: '> primary | seriesByIndex(0) | delta(-2)'
2206
- };
2207
- var optionsToRename = {
2208
- useTrendUnits: 'shouldAbbreviateTrendValue',
2209
- useThousandSeparators: 'shouldUseThousandSeparators',
2210
- deltaColor: 'trendColor',
2211
- color: 'iconColor'
2212
- };
2213
-
2214
- var migrateVizToSplunkSingleValueIcon = function migrateVizToSplunkSingleValueIcon(vizDefinition) {
2215
- var _a, _b, _c;
2216
-
2217
- var _vizDefinition$option = vizDefinition.options,
2218
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2219
- _vizDefinition$encodi = vizDefinition.encoding,
2220
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2221
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
2222
-
2223
- var migratedVisualization = Object.assign(Object.assign({}, otherDefinitionParts), {
2224
- type: 'splunk.singlevalueicon',
867
+ var migrateVizToSplunkSingleValue = (vizDefinition) => {
868
+ var _b, _c, _d;
869
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
870
+ const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
871
+ type: "splunk.singlevalue",
2225
872
  context: {},
2226
873
  options: {}
2227
874
  });
2228
-
2229
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2230
- dataOptions = _ref.options,
2231
- dataContext = _ref.context;
2232
-
2233
- var migratedDataOptions = Object.assign(Object.assign({}, (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.trend) && {
2234
- majorValue: (_a = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.trend, 'lastPoint()')) !== null && _a !== void 0 ? _a : dataOptions.trend,
2235
- trendValue: (_b = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.trend, 'delta(-2)')) !== null && _b !== void 0 ? _b : dataOptions.trend
2236
- }), (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.fill) && {
2237
- backgroundColor: (_c = (0, migrationUtils_1.preserveDataSelectionForValueOption)(dataOptions.fill, 'lastPoint()')) !== null && _c !== void 0 ? _c : dataOptions.fill
875
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
876
+ encoding
877
+ );
878
+ const migratedDataOptions = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (dataOptions == null ? void 0 : dataOptions.trend) && { sparklineValues: dataOptions.trend }), (dataOptions == null ? void 0 : dataOptions.majorColor) && {
879
+ majorColor: (_b = preserveDataSelectionForValueOption(dataOptions.majorColor, "lastPoint()")) != null ? _b : dataOptions.majorColor
880
+ }), (dataOptions == null ? void 0 : dataOptions.deltaColor) && {
881
+ trendColor: (_c = preserveDataSelectionForValueOption(dataOptions.deltaColor, "lastPoint()")) != null ? _c : dataOptions.deltaColor
882
+ }), (dataOptions == null ? void 0 : dataOptions.fill) && {
883
+ backgroundColor: (_d = preserveDataSelectionForValueOption(dataOptions.fill, "lastPoint()")) != null ? _d : dataOptions.fill
2238
884
  });
2239
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionsToRename);
2240
- var trendDisplayMode = renamedOptions.trendDisplayMode,
2241
- showTrendIndicator = renamedOptions.showTrendIndicator;
2242
- var trendDisplay = (0, singlevalue_1.consolidateTrendDisplay)(trendDisplayMode, showTrendIndicator);
2243
- migratedVisualization.options = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultsToRetain), renamedOptions), migratedDataOptions), typeof trendDisplay === 'string' && {
2244
- trendDisplay: trendDisplay
2245
- });
2246
- migratedVisualization.context = dataContext; // remove invalid (and deprecated) options using the optionsSchema for splunk.singlevalueicon as reference
2247
-
2248
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.singleValueIconOptionsSchema);
2249
- return migratedVisualization;
2250
- };
2251
-
2252
- exports.migrateVizToSplunkSingleValueIcon = migrateVizToSplunkSingleValueIcon;
2253
-
2254
- /***/ }),
2255
- /* 32 */
2256
- /***/ (function(module, exports, __webpack_require__) {
2257
-
2258
- "use strict";
2259
-
2260
-
2261
- var __rest = this && this.__rest || function (s, e) {
2262
- var t = {};
2263
-
2264
- for (var p in s) {
2265
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2266
- }
2267
-
2268
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2269
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2270
- }
2271
- return t;
885
+ const renamedOptions = renameVizOptions(options, optionRenames5);
886
+ const { trendDisplayMode, showTrendIndicator, showSparkline, sparklinePosition } = renamedOptions;
887
+ const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
888
+ const sparklineDisplay = consolidateSparklineDisplay(
889
+ sparklinePosition,
890
+ showSparkline
891
+ );
892
+ migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay }), typeof sparklineDisplay === "string" && { sparklineDisplay });
893
+ migratedVisualization.context = dataContext;
894
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueOptionsSchema);
895
+ return migratedVisualization;
2272
896
  };
2273
897
 
2274
- Object.defineProperty(exports, "__esModule", {
2275
- value: true
2276
- });
2277
- exports.migrateVizToSplunkSingleValueRadial = void 0;
2278
-
2279
- var visualization_schemas_1 = __webpack_require__(0);
2280
-
2281
- var encoding_1 = __webpack_require__(2);
2282
-
2283
- var migrationUtils_1 = __webpack_require__(1);
2284
-
2285
- var singlevalue_1 = __webpack_require__(4); // old default configurations should be retained in migrated configuration
2286
-
2287
-
2288
- var defaultsToRetain = {
2289
- majorValue: '> primary | seriesByIndex(0) | lastPoint()',
2290
- trendValue: '> primary | seriesByIndex(0) | delta(-2)'
898
+ // src/visualizations/singlevalueicon.ts
899
+ var defaultsToRetain2 = {
900
+ majorValue: "> primary | seriesByIndex(0) | lastPoint()",
901
+ trendValue: "> primary | seriesByIndex(0) | delta(-2)"
2291
902
  };
2292
- var optionRenames = {
2293
- useTrendUnits: 'shouldAbbreviateTrendValue',
2294
- useThousandSeparators: 'shouldUseThousandSeparators'
903
+ var optionsToRename3 = {
904
+ useTrendUnits: "shouldAbbreviateTrendValue",
905
+ useThousandSeparators: "shouldUseThousandSeparators",
906
+ deltaColor: "trendColor",
907
+ color: "iconColor"
2295
908
  };
2296
-
2297
- var migrateVizToSplunkSingleValueRadial = function migrateVizToSplunkSingleValueRadial(vizDefinition) {
2298
- var _a, _b, _c;
2299
-
2300
- var _vizDefinition$option = vizDefinition.options,
2301
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2302
- _vizDefinition$encodi = vizDefinition.encoding,
2303
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2304
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
2305
-
2306
- var migratedVisualization = Object.assign(Object.assign({}, otherDefinitionParts), {
2307
- type: 'splunk.singlevalueradial',
909
+ var migrateVizToSplunkSingleValueIcon = (vizDefinition) => {
910
+ var _b, _c, _d;
911
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
912
+ const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
913
+ type: "splunk.singlevalueicon",
2308
914
  context: {},
2309
915
  options: {}
2310
916
  });
2311
-
2312
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2313
- dataOptions = _ref.options,
2314
- dataContext = _ref.context;
2315
-
2316
- var originalTrend = dataOptions.trend,
2317
- originalFill = dataOptions.fill;
2318
- var migratedDataOptions = Object.assign(Object.assign({}, originalTrend && {
2319
- majorValue: (_a = (0, migrationUtils_1.preserveDataSelectionForValueOption)(originalTrend, 'lastPoint()')) !== null && _a !== void 0 ? _a : originalTrend,
2320
- trendValue: (_b = (0, migrationUtils_1.preserveDataSelectionForValueOption)(originalTrend, 'delta(-2)')) !== null && _b !== void 0 ? _b : originalTrend
2321
- }), originalFill && {
2322
- backgroundColor: (_c = (0, migrationUtils_1.preserveDataSelectionForValueOption)(originalFill, 'lastPoint()')) !== null && _c !== void 0 ? _c : originalFill
2323
- });
2324
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
2325
- var trendDisplayMode = renamedOptions.trendDisplayMode,
2326
- showTrendIndicator = renamedOptions.showTrendIndicator;
2327
- var trendDisplay = (0, singlevalue_1.consolidateTrendDisplay)(trendDisplayMode, showTrendIndicator);
2328
- migratedVisualization.options = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultsToRetain), renamedOptions), migratedDataOptions), typeof trendDisplay === 'string' && {
2329
- trendDisplay: trendDisplay
917
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
918
+ encoding
919
+ );
920
+ const migratedDataOptions = __spreadValues(__spreadValues({}, (dataOptions == null ? void 0 : dataOptions.trend) && {
921
+ majorValue: (_b = preserveDataSelectionForValueOption(dataOptions.trend, "lastPoint()")) != null ? _b : dataOptions.trend,
922
+ trendValue: (_c = preserveDataSelectionForValueOption(dataOptions.trend, "delta(-2)")) != null ? _c : dataOptions.trend
923
+ }), (dataOptions == null ? void 0 : dataOptions.fill) && {
924
+ backgroundColor: (_d = preserveDataSelectionForValueOption(dataOptions.fill, "lastPoint()")) != null ? _d : dataOptions.fill
2330
925
  });
2331
- migratedVisualization.context = dataContext; // remove invalid (and deprecated) options using the optionsSchema for splunk.singlevalueradial as reference
2332
-
2333
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.singleValueRadialOptionsSchema);
926
+ const renamedOptions = renameVizOptions(options, optionsToRename3);
927
+ const { trendDisplayMode, showTrendIndicator } = renamedOptions;
928
+ const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
929
+ migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain2), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay });
930
+ migratedVisualization.context = dataContext;
931
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueIconOptionsSchema);
2334
932
  return migratedVisualization;
2335
933
  };
2336
934
 
2337
- exports.migrateVizToSplunkSingleValueRadial = migrateVizToSplunkSingleValueRadial;
2338
-
2339
- /***/ }),
2340
- /* 33 */
2341
- /***/ (function(module, exports, __webpack_require__) {
2342
-
2343
- "use strict";
2344
-
2345
-
2346
- var _slicedToArray = __webpack_require__(7);
2347
-
2348
- var __rest = this && this.__rest || function (s, e) {
2349
- var t = {};
2350
-
2351
- for (var p in s) {
2352
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2353
- }
2354
-
2355
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2356
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2357
- }
2358
- return t;
935
+ // src/visualizations/singlevalueradial.ts
936
+ var defaultsToRetain3 = {
937
+ majorValue: "> primary | seriesByIndex(0) | lastPoint()",
938
+ trendValue: "> primary | seriesByIndex(0) | delta(-2)"
939
+ };
940
+ var optionRenames6 = {
941
+ useTrendUnits: "shouldAbbreviateTrendValue",
942
+ useThousandSeparators: "shouldUseThousandSeparators"
943
+ };
944
+ var migrateVizToSplunkSingleValueRadial = (vizDefinition) => {
945
+ var _b, _c, _d;
946
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
947
+ const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
948
+ type: "splunk.singlevalueradial",
949
+ context: {},
950
+ options: {}
951
+ });
952
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
953
+ encoding
954
+ );
955
+ const { trend: originalTrend, fill: originalFill } = dataOptions;
956
+ const migratedDataOptions = __spreadValues(__spreadValues({}, originalTrend && {
957
+ majorValue: (_b = preserveDataSelectionForValueOption(originalTrend, "lastPoint()")) != null ? _b : originalTrend,
958
+ trendValue: (_c = preserveDataSelectionForValueOption(originalTrend, "delta(-2)")) != null ? _c : originalTrend
959
+ }), originalFill && {
960
+ backgroundColor: (_d = preserveDataSelectionForValueOption(originalFill, "lastPoint()")) != null ? _d : originalFill
961
+ });
962
+ const renamedOptions = renameVizOptions(options, optionRenames6);
963
+ const { trendDisplayMode, showTrendIndicator } = renamedOptions;
964
+ const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
965
+ migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain3), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay });
966
+ migratedVisualization.context = dataContext;
967
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueRadialOptionsSchema);
968
+ return migratedVisualization;
2359
969
  };
2360
970
 
2361
- Object.defineProperty(exports, "__esModule", {
2362
- value: true
971
+ // esm-externals:lodash
972
+ var lodash_exports = {};
973
+ __export(lodash_exports, {
974
+ default: () => lodash_default
2363
975
  });
2364
- exports.migrateVizToSplunkTable = void 0;
2365
-
2366
- var lodash_1 = __webpack_require__(9);
2367
-
2368
- var visualization_schemas_1 = __webpack_require__(0);
2369
-
2370
- var deepMergeWithArrayPrimitiveOverrides_1 = __webpack_require__(34);
2371
-
2372
- var encoding_1 = __webpack_require__(2);
2373
-
2374
- var migrationUtils_1 = __webpack_require__(1); // old default configurations should be retained in migrated configuration
2375
-
976
+ var defaultImport4 = __toESM(require("lodash"));
977
+ __reExport(lodash_exports, require("lodash"));
978
+ var lodash_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
979
+
980
+ // esm-externals:@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides
981
+ var deepMergeWithArrayPrimitiveOverrides_exports = {};
982
+ __export(deepMergeWithArrayPrimitiveOverrides_exports, {
983
+ default: () => deepMergeWithArrayPrimitiveOverrides_default
984
+ });
985
+ var defaultImport5 = __toESM(require("@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides"));
986
+ __reExport(deepMergeWithArrayPrimitiveOverrides_exports, require("@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides"));
987
+ var deepMergeWithArrayPrimitiveOverrides_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
2376
988
 
2377
- var defaultChanges = {
989
+ // src/visualizations/table.ts
990
+ var defaultChanges9 = {
2378
991
  count: 20
2379
992
  };
2380
- var optionRenames = {
2381
- rowNumbers: 'showRowNumbers'
993
+ var optionRenames7 = {
994
+ rowNumbers: "showRowNumbers"
2382
995
  };
2383
-
2384
- var migrateHeaderVisibility = function migrateHeaderVisibility(oldHeaderVisibility) {
2385
- if (oldHeaderVisibility === undefined) {
2386
- // headerVisibility: 'inline' is the default in splunk.table
2387
- // this corresponds to `showHeader: true`, which is the default in viz.table
2388
- return undefined;
996
+ var migrateHeaderVisibility = (oldHeaderVisibility) => {
997
+ if (oldHeaderVisibility === void 0) {
998
+ return void 0;
2389
999
  }
2390
-
2391
- return oldHeaderVisibility ? 'inline' : 'none';
1000
+ return oldHeaderVisibility ? "inline" : "none";
2392
1001
  };
2393
- /**
2394
- * Helper to migrate alternating color options (text and background) to their corresponding DSL and context configs
2395
- */
2396
-
2397
-
2398
- var migrateAlternatingColors = function migrateAlternatingColors(colors, optionToConvert, contextConfigName) {
2399
- // default alternating themed color values as defined in table config
2400
- var themedAlternatingColors = {
1002
+ var migrateAlternatingColors = (colors, optionToConvert, contextConfigName) => {
1003
+ const themedAlternatingColors = {
2401
1004
  rowBackgroundColors: {
2402
- even: '> themes.rowBackgroundColorEven',
2403
- odd: '> themes.rowBackgroundColorOdd'
1005
+ even: "> themes.rowBackgroundColorEven",
1006
+ odd: "> themes.rowBackgroundColorOdd"
2404
1007
  },
2405
1008
  rowColors: {
2406
- even: '> themes.inverseTextColor',
2407
- odd: '> themes.textColor'
1009
+ even: "> themes.inverseTextColor",
1010
+ odd: "> themes.textColor"
2408
1011
  }
2409
1012
  };
2410
- var colorsContext = [];
2411
- var oddColor = colors.oddColor,
2412
- evenColor = colors.evenColor;
2413
-
1013
+ const colorsContext = [];
1014
+ const { oddColor, evenColor } = colors;
2414
1015
  if (oddColor && evenColor) {
2415
- colorsContext.push.apply(colorsContext, [oddColor, evenColor]);
1016
+ colorsContext.push(...[oddColor, evenColor]);
2416
1017
  } else if (oddColor) {
2417
- colorsContext.push.apply(colorsContext, [oddColor, themedAlternatingColors[optionToConvert].even]);
1018
+ colorsContext.push(...[oddColor, themedAlternatingColors[optionToConvert].even]);
2418
1019
  } else if (evenColor) {
2419
- colorsContext.push.apply(colorsContext, [themedAlternatingColors[optionToConvert].odd, evenColor]);
1020
+ colorsContext.push(...[themedAlternatingColors[optionToConvert].odd, evenColor]);
2420
1021
  }
2421
-
2422
1022
  if (colorsContext.length) {
2423
1023
  return {
2424
- contextConfigName: contextConfigName,
1024
+ contextConfigName,
2425
1025
  context: colorsContext,
2426
- dsl: "> table | pick(".concat(contextConfigName, ")")
1026
+ dsl: `> table | pick(${contextConfigName})`
2427
1027
  };
2428
1028
  }
2429
-
2430
1029
  return {};
2431
1030
  };
2432
- /**
2433
- * Intermediate helper to translate column-specific formatting in viz.table to their DSL equivalents
2434
- * viz.table defines column-specific formatting via entries specified in options.fields.<columnName>
2435
- *
2436
- * This requires moving numberPrecision, useThousandSeparators, unitPosition, and other formatting options to the config
2437
- * The resultant config is used as the argument for formatByType
2438
- */
2439
-
2440
-
2441
- var migrateToColumnFormat = function migrateToColumnFormat(fieldsOption) {
2442
- var columnFormat = {};
2443
- var columnFormatContext = {};
2444
-
1031
+ var migrateToColumnFormat = (fieldsOption) => {
1032
+ const columnFormat = {};
1033
+ const columnFormatContext = {};
2445
1034
  if (!fieldsOption) {
2446
1035
  return {
2447
- columnFormat: columnFormat,
2448
- columnFormatContext: columnFormatContext
1036
+ columnFormat,
1037
+ columnFormatContext
2449
1038
  };
2450
1039
  }
2451
-
2452
- Object.entries(fieldsOption).forEach(function (_ref) {
2453
- var _ref2 = _slicedToArray(_ref, 2),
2454
- column = _ref2[0],
2455
- formatting = _ref2[1];
2456
-
2457
- // need to prepend `formatted` in case the column has leading digits, which the nearley parser cannot account for
2458
- var contextEntry = "formatted".concat(column, "Config");
1040
+ Object.entries(fieldsOption).forEach(([column, formatting]) => {
1041
+ const contextEntry = `formatted${column}Config`;
2459
1042
  columnFormatContext[contextEntry] = {};
2460
1043
  columnFormat[column] = {
2461
- data: "> table | seriesByName(\"".concat(column, "\") | formatByType(").concat(contextEntry, ")")
2462
- }; // all columnFormatting options are optional; if they are not present in the original config, tableFormat should take precedence
2463
-
2464
- var unit = formatting.unit,
2465
- unitPosition = formatting.unitPosition,
2466
- numberPrecision = formatting.numberPrecision,
2467
- useThousandSeparators = formatting.useThousandSeparators;
2468
-
2469
- if (typeof unitPosition === 'string') {
2470
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'number', 'unitPosition'], unitPosition);
2471
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'string', 'unitPosition'], unitPosition);
1044
+ data: `> table | seriesByName("${column}") | formatByType(${contextEntry})`
1045
+ };
1046
+ const { unit, unitPosition, numberPrecision, useThousandSeparators } = formatting;
1047
+ if (typeof unitPosition === "string") {
1048
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "unitPosition"], unitPosition);
1049
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "string", "unitPosition"], unitPosition);
2472
1050
  }
2473
-
2474
- if (typeof unit === 'string' || typeof unit === 'number') {
2475
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'number', 'unit'], unit);
2476
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'string', 'unit'], unit);
1051
+ if (typeof unit === "string" || typeof unit === "number") {
1052
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "unit"], unit);
1053
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "string", "unit"], unit);
2477
1054
  }
2478
-
2479
1055
  if (numberPrecision != null) {
2480
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'number', 'precision'], numberPrecision);
1056
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "precision"], numberPrecision);
2481
1057
  }
2482
-
2483
1058
  if (useThousandSeparators != null) {
2484
- (0, lodash_1.set)(columnFormatContext, [contextEntry, 'number', 'thousandSeparated'], useThousandSeparators);
1059
+ (0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "thousandSeparated"], useThousandSeparators);
2485
1060
  }
2486
1061
  });
2487
1062
  return {
2488
- columnFormat: columnFormat,
2489
- columnFormatContext: columnFormatContext
1063
+ columnFormat,
1064
+ columnFormatContext
2490
1065
  };
2491
1066
  };
2492
- /**
2493
- * Intermediate helper to translate table-wide formatting and coloring in viz.table to their DSL equivalents
2494
- *
2495
- * This requires moving numberPrecision, useThousandSeparators, unitPosition, and other formatting/coloring options to the config
2496
- * The resultant formatting and coloring config is used as the argument for the formatByType() and pick() DSL formatters respectively
2497
- */
2498
-
2499
-
2500
- var migrateToTableFormat = function migrateToTableFormat() {
2501
- var oldOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2502
- var tableFormat = {};
2503
- var tableFormatContext = {
1067
+ var migrateToTableFormat = (oldOptions = {}) => {
1068
+ const tableFormat = {};
1069
+ const tableFormatContext = {
2504
1070
  formattedConfig: {}
2505
1071
  };
2506
- var unit = oldOptions.unit,
2507
- oldUnitPosition = oldOptions.unitPosition,
2508
- oldNumberPrecision = oldOptions.numberPrecision,
2509
- oldUseThousandSeparators = oldOptions.useThousandSeparators;
2510
- var unitPosition = typeof oldUnitPosition === 'string' ? oldUnitPosition : 'after';
2511
- var numberPrecision = typeof oldNumberPrecision === 'number' ? oldNumberPrecision : 0;
2512
- var useThousandSeparators = typeof oldUseThousandSeparators === 'boolean' ? oldUseThousandSeparators : false;
2513
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'number', 'precision'], numberPrecision);
2514
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'number', 'thousandSeparated'], useThousandSeparators);
2515
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'number', 'unitPosition'], unitPosition);
2516
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'string', 'unitPosition'], unitPosition);
2517
-
2518
- if (typeof unit === 'string' || typeof unit === 'number') {
2519
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'number', 'unit'], unit);
2520
- (0, lodash_1.set)(tableFormatContext, ['formattedConfig', 'string', 'unit'], unit);
2521
- }
2522
-
2523
- tableFormat.data = "> table | formatByType(formattedConfig)";
2524
- var rowBackgroundColorEven = oldOptions.rowBackgroundColorEven,
2525
- rowBackgroundColorOdd = oldOptions.rowBackgroundColorOdd,
2526
- rowTextColorOdd = oldOptions.rowTextColorOdd,
2527
- rowTextColorEven = oldOptions.rowTextColorEven,
2528
- headerTextColor = oldOptions.headerTextColor,
2529
- headerBackgroundColor = oldOptions.headerBackgroundColor;
2530
-
2531
- var _migrateAlternatingCo = migrateAlternatingColors({
2532
- oddColor: rowTextColorOdd,
2533
- evenColor: rowTextColorEven
2534
- }, 'rowColors', 'rowColorsConfig'),
2535
- rowColorsContext = _migrateAlternatingCo.context,
2536
- rowColorsDSL = _migrateAlternatingCo.dsl;
2537
-
1072
+ const {
1073
+ unit,
1074
+ unitPosition: oldUnitPosition,
1075
+ numberPrecision: oldNumberPrecision,
1076
+ useThousandSeparators: oldUseThousandSeparators
1077
+ } = oldOptions;
1078
+ const unitPosition = typeof oldUnitPosition === "string" ? oldUnitPosition : "after";
1079
+ const numberPrecision = typeof oldNumberPrecision === "number" ? oldNumberPrecision : 0;
1080
+ const useThousandSeparators = typeof oldUseThousandSeparators === "boolean" ? oldUseThousandSeparators : false;
1081
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "precision"], numberPrecision);
1082
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "thousandSeparated"], useThousandSeparators);
1083
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "unitPosition"], unitPosition);
1084
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "string", "unitPosition"], unitPosition);
1085
+ if (typeof unit === "string" || typeof unit === "number") {
1086
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "unit"], unit);
1087
+ (0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "string", "unit"], unit);
1088
+ }
1089
+ tableFormat.data = `> table | formatByType(formattedConfig)`;
1090
+ const {
1091
+ rowBackgroundColorEven,
1092
+ rowBackgroundColorOdd,
1093
+ rowTextColorOdd,
1094
+ rowTextColorEven,
1095
+ headerTextColor,
1096
+ headerBackgroundColor
1097
+ } = oldOptions;
1098
+ const { context: rowColorsContext, dsl: rowColorsDSL } = migrateAlternatingColors(
1099
+ { oddColor: rowTextColorOdd, evenColor: rowTextColorEven },
1100
+ "rowColors",
1101
+ "rowColorsConfig"
1102
+ );
2538
1103
  if (rowColorsContext && rowColorsDSL) {
2539
1104
  tableFormatContext.rowColorsConfig = rowColorsContext;
2540
1105
  tableFormat.rowColors = rowColorsDSL;
2541
1106
  }
2542
-
2543
- var _migrateAlternatingCo2 = migrateAlternatingColors({
2544
- oddColor: rowBackgroundColorOdd,
2545
- evenColor: rowBackgroundColorEven
2546
- }, 'rowBackgroundColors', 'rowBackgroundColorsConfig'),
2547
- rowBackgroundColorsContext = _migrateAlternatingCo2.context,
2548
- rowBackgroundColorsDSL = _migrateAlternatingCo2.dsl;
2549
-
1107
+ const { context: rowBackgroundColorsContext, dsl: rowBackgroundColorsDSL } = migrateAlternatingColors(
1108
+ { oddColor: rowBackgroundColorOdd, evenColor: rowBackgroundColorEven },
1109
+ "rowBackgroundColors",
1110
+ "rowBackgroundColorsConfig"
1111
+ );
2550
1112
  if (rowBackgroundColorsContext && rowBackgroundColorsDSL) {
2551
1113
  tableFormat.rowBackgroundColors = rowBackgroundColorsDSL;
2552
1114
  tableFormatContext.rowBackgroundColorsConfig = rowBackgroundColorsContext;
2553
1115
  }
2554
-
2555
1116
  if (headerTextColor) {
2556
1117
  tableFormat.headerColor = headerTextColor;
2557
1118
  }
2558
-
2559
1119
  if (headerBackgroundColor) {
2560
1120
  tableFormat.headerBackgroundColor = headerBackgroundColor;
2561
1121
  }
2562
-
2563
1122
  return {
2564
- tableFormat: tableFormat,
2565
- tableFormatContext: tableFormatContext
1123
+ tableFormat,
1124
+ tableFormatContext
2566
1125
  };
2567
1126
  };
2568
-
2569
- var migrateVizToSplunkTable = function migrateVizToSplunkTable(vizDefinition) {
2570
- var _vizDefinition$encodi = vizDefinition.encoding,
2571
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2572
- _vizDefinition$option = vizDefinition.options,
2573
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2574
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
2575
-
2576
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
2577
- type: 'splunk.table',
1127
+ var migrateVizToSplunkTable = (vizDefinition) => {
1128
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
1129
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
1130
+ type: "splunk.table",
2578
1131
  options: {},
2579
1132
  context: {}
2580
1133
  });
2581
-
2582
- var _ref3 = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2583
- dataOptions = _ref3.options,
2584
- dataContext = _ref3.context;
2585
-
2586
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
2587
- var headerVisibility = migrateHeaderVisibility(renamedOptions.showHeader);
2588
-
2589
- var _migrateToTableFormat = migrateToTableFormat(renamedOptions),
2590
- tableFormat = _migrateToTableFormat.tableFormat,
2591
- tableFormatContext = _migrateToTableFormat.tableFormatContext;
2592
-
2593
- var _migrateToColumnForma = migrateToColumnFormat(renamedOptions.fields),
2594
- columnFormat = _migrateToColumnForma.columnFormat,
2595
- columnFormatContext = _migrateToColumnForma.columnFormatContext;
2596
-
2597
- var migratedDataOptions = Object.assign({}, (dataOptions === null || dataOptions === void 0 ? void 0 : dataOptions.columns) && {
2598
- table: dataOptions.columns
2599
- });
2600
- var formattingOptions = Object.assign(Object.assign(Object.assign({}, !(0, lodash_1.isEmpty)(columnFormat) && {
2601
- columnFormat: columnFormat
2602
- }), typeof headerVisibility === 'string' && {
2603
- headerVisibility: headerVisibility
2604
- }), {
2605
- tableFormat: tableFormat
1134
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
1135
+ encoding
1136
+ );
1137
+ const renamedOptions = renameVizOptions(options, optionRenames7);
1138
+ const headerVisibility = migrateHeaderVisibility(renamedOptions.showHeader);
1139
+ const { tableFormat, tableFormatContext } = migrateToTableFormat(renamedOptions);
1140
+ const { columnFormat, columnFormatContext } = migrateToColumnFormat(
1141
+ renamedOptions.fields
1142
+ );
1143
+ const migratedDataOptions = __spreadValues({}, (dataOptions == null ? void 0 : dataOptions.columns) && { table: dataOptions.columns });
1144
+ const formattingOptions = __spreadProps(__spreadValues(__spreadValues({}, !(0, lodash_exports.isEmpty)(columnFormat) && { columnFormat }), typeof headerVisibility === "string" && { headerVisibility }), {
1145
+ tableFormat
2606
1146
  });
2607
- var migratedOptions = (0, deepMergeWithArrayPrimitiveOverrides_1.deepMergeWithArrayPrimitiveOverrides)({}, defaultChanges, formattingOptions, migratedDataOptions, renamedOptions); // remove invalid options
2608
-
2609
- Object.keys(migratedOptions).forEach(function (key) {
2610
- if (!visualization_schemas_1.tableOptionsSchema[key]) {
1147
+ const migratedOptions = (0, deepMergeWithArrayPrimitiveOverrides_exports.deepMergeWithArrayPrimitiveOverrides)(
1148
+ {},
1149
+ defaultChanges9,
1150
+ formattingOptions,
1151
+ migratedDataOptions,
1152
+ renamedOptions
1153
+ );
1154
+ Object.keys(migratedOptions).forEach((key) => {
1155
+ if (!visualization_schemas_exports.tableOptionsSchema[key]) {
2611
1156
  delete migratedOptions[key];
2612
1157
  }
2613
1158
  });
2614
- migratedDefinition.context = Object.assign(Object.assign(Object.assign({}, dataContext), !(0, lodash_1.isEmpty)(columnFormatContext) && Object.assign({}, columnFormatContext)), tableFormatContext);
1159
+ migratedDefinition.context = __spreadValues(__spreadValues(__spreadValues({}, dataContext), !(0, lodash_exports.isEmpty)(columnFormatContext) && __spreadValues({}, columnFormatContext)), tableFormatContext);
2615
1160
  migratedDefinition.options = migratedOptions;
2616
1161
  return migratedDefinition;
2617
1162
  };
2618
1163
 
2619
- exports.migrateVizToSplunkTable = migrateVizToSplunkTable;
2620
-
2621
- /***/ }),
2622
- /* 34 */
2623
- /***/ (function(module, exports) {
2624
-
2625
- module.exports = require("@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides");
2626
-
2627
- /***/ }),
2628
- /* 35 */
2629
- /***/ (function(module, exports, __webpack_require__) {
2630
-
2631
- "use strict";
2632
-
2633
-
2634
- var __rest = this && this.__rest || function (s, e) {
2635
- var t = {};
2636
-
2637
- for (var p in s) {
2638
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2639
- }
2640
-
2641
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2642
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2643
- }
2644
- return t;
2645
- };
2646
-
2647
- Object.defineProperty(exports, "__esModule", {
2648
- value: true
2649
- });
2650
- exports.migrateVizTextToSplunkMarkdown = exports.convertFontSize = void 0;
2651
-
2652
- var _ = __webpack_require__(9);
2653
-
2654
- var visualization_schemas_1 = __webpack_require__(0);
2655
-
2656
- var migrationUtils_1 = __webpack_require__(1);
2657
-
2658
- var optionsToRename = {
2659
- textColor: 'fontColor',
2660
- content: 'markdown'
1164
+ // src/visualizations/text.ts
1165
+ var optionsToRename4 = {
1166
+ textColor: "fontColor",
1167
+ content: "markdown"
2661
1168
  };
2662
-
2663
- var convertTextContentToMarkDown = function convertTextContentToMarkDown(fontWeight, fontSize) {
2664
- var textContent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2665
-
2666
- if (!_.isNumber(fontSize)) {
1169
+ var convertTextContentToMarkDown = (fontWeight, fontSize, textContent = "") => {
1170
+ if (!lodash_exports.isNumber(fontSize)) {
2667
1171
  return textContent;
2668
1172
  }
2669
-
2670
1173
  if (textContent.trim().length === 0) {
2671
1174
  return textContent;
2672
- } // Remove any trailing newline chars from the content
2673
-
2674
-
2675
- var markdownContent = textContent.replace(/\n*$/, ''); // Handle text conversion to marker tags based on fontSize and fontWeight
2676
-
2677
- var regex = /\n/g; // regex to match /n with global scope across the string
2678
- // Convert to paragraph in markdown, if fontSize < 20,
2679
- // If text has fontWeight set to 'bold', add bold tag (**{markdown}**)
2680
-
2681
- if (fontWeight === 'bold') {
2682
- // Here direct regex replace doesnt work, as we need to remove the
2683
- // extra trailing space if any exist before appending **{markdown}** to the text
2684
- var contentStrings = markdownContent.split('\n');
2685
- var stringsTrimmed = contentStrings.map(function (str) {
2686
- return str && str.trim().length ? "**".concat(str.trim(), "**") : '';
2687
- }); // Remove all blank entries from the end of the trimmed string array,
2688
- // to avoid `\` to get rendered, which happens if following line after `\\n` is empty)
2689
-
2690
- var idx = stringsTrimmed.length - 1;
2691
-
1175
+ }
1176
+ let markdownContent = textContent.replace(/\n*$/, "");
1177
+ const regex = /\n/g;
1178
+ if (fontWeight === "bold") {
1179
+ const contentStrings = markdownContent.split("\n");
1180
+ const stringsTrimmed = contentStrings.map(
1181
+ (str) => str && str.trim().length ? `**${str.trim()}**` : ""
1182
+ );
1183
+ let idx = stringsTrimmed.length - 1;
2692
1184
  while (idx >= 0 && stringsTrimmed[idx].length === 0) {
2693
1185
  stringsTrimmed.pop();
2694
1186
  idx -= 1;
2695
1187
  }
2696
-
2697
- return stringsTrimmed.join('\\\n');
2698
- } // If fontWeight is not bold, replace '\n' with '\\n` using regex
2699
-
2700
-
2701
- markdownContent = markdownContent.replace(regex, '\\\n');
2702
- return markdownContent;
2703
- };
2704
-
2705
- var convertFontSize = function convertFontSize(fontSize) {
2706
- if (!_.isNumber(fontSize)) {
2707
- return {
2708
- fontSize: 'default'
2709
- };
1188
+ return stringsTrimmed.join("\\\n");
2710
1189
  }
2711
-
2712
- return {
2713
- fontSize: 'custom',
2714
- customFontSize: fontSize
2715
- };
1190
+ markdownContent = markdownContent.replace(regex, "\\\n");
1191
+ return markdownContent;
2716
1192
  };
2717
-
2718
- exports.convertFontSize = convertFontSize;
2719
-
2720
- var migrateVizTextToSplunkMarkdown = function migrateVizTextToSplunkMarkdown(vizDefinition) {
2721
- var _vizDefinition$option = vizDefinition.options,
2722
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2723
- otherDefinitionParts = __rest(vizDefinition, ["options"]);
2724
-
2725
- var _options$fontSize = options.fontSize,
2726
- fontSize = _options$fontSize === void 0 ? 24 : _options$fontSize,
2727
- _options$fontWeight = options.fontWeight,
2728
- fontWeight = _options$fontWeight === void 0 ? 'normal' : _options$fontWeight,
2729
- _options$fontFamily = options.fontFamily,
2730
- fontFamily = _options$fontFamily === void 0 ? 'Splunk Platform Sans' : _options$fontFamily,
2731
- _options$rotation = options.rotation,
2732
- rotation = _options$rotation === void 0 ? 0 : _options$rotation;
2733
- var migratedVisualization = Object.assign(Object.assign({
2734
- options: options
2735
- }, otherDefinitionParts), {
2736
- type: 'splunk.markdown',
2737
- context: {}
2738
- }); // perform any option renames
2739
-
2740
- migratedVisualization.options = (0, migrationUtils_1.renameVizOptions)(migratedVisualization.options, optionsToRename);
2741
- var migratedVizOptions = migratedVisualization.options; // convert text content to respective markdown
2742
-
2743
- migratedVizOptions.markdown = convertTextContentToMarkDown(fontWeight, fontSize, migratedVizOptions.markdown); // convert text fontSize to markdown fontSize
2744
-
2745
- var _ref = (0, exports.convertFontSize)(fontSize),
2746
- fontSizeValue = _ref.fontSize,
2747
- customFontSize = _ref.customFontSize;
2748
-
1193
+ var convertFontSize = (fontSize) => {
1194
+ if (!lodash_exports.isNumber(fontSize)) {
1195
+ return { fontSize: "default" };
1196
+ }
1197
+ return { fontSize: "custom", customFontSize: fontSize };
1198
+ };
1199
+ var migrateVizTextToSplunkMarkdown = (vizDefinition) => {
1200
+ const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
1201
+ const {
1202
+ fontSize = 24,
1203
+ fontWeight = "normal",
1204
+ fontFamily = "Splunk Platform Sans",
1205
+ rotation = 0
1206
+ } = options;
1207
+ const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.markdown", context: {} });
1208
+ migratedVisualization.options = renameVizOptions(migratedVisualization.options, optionsToRename4);
1209
+ const migratedVizOptions = migratedVisualization.options;
1210
+ migratedVizOptions.markdown = convertTextContentToMarkDown(
1211
+ fontWeight,
1212
+ fontSize,
1213
+ migratedVizOptions.markdown
1214
+ );
1215
+ const { fontSize: fontSizeValue, customFontSize } = convertFontSize(fontSize);
2749
1216
  migratedVizOptions.fontSize = fontSizeValue;
2750
1217
  migratedVizOptions.customFontSize = customFontSize;
2751
1218
  migratedVizOptions.fontFamily = fontFamily;
2752
- migratedVizOptions.rotation = rotation; // remove invalid options using the optionsSchema for splunk.markdown as reference
2753
-
2754
- (0, migrationUtils_1.removeInvalidOptions)(migratedVizOptions, visualization_schemas_1.markdownOptionsSchema);
1219
+ migratedVizOptions.rotation = rotation;
1220
+ removeInvalidOptions(migratedVizOptions, visualization_schemas_exports.markdownOptionsSchema);
2755
1221
  return migratedVisualization;
2756
1222
  };
2757
1223
 
2758
- exports.migrateVizTextToSplunkMarkdown = migrateVizTextToSplunkMarkdown;
2759
-
2760
- /***/ }),
2761
- /* 36 */
2762
- /***/ (function(module, exports, __webpack_require__) {
2763
-
2764
- "use strict";
2765
-
2766
-
2767
- var _toConsumableArray = __webpack_require__(6);
2768
-
2769
- var __rest = this && this.__rest || function (s, e) {
2770
- var t = {};
2771
-
2772
- for (var p in s) {
2773
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2774
- }
2775
-
2776
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2777
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2778
- }
2779
- return t;
2780
- };
2781
-
2782
- Object.defineProperty(exports, "__esModule", {
2783
- value: true
2784
- });
2785
- exports.migrateVizToSplunkPunchcard = void 0;
2786
-
2787
- var visualization_schemas_1 = __webpack_require__(0);
2788
-
2789
- var encoding_1 = __webpack_require__(2);
2790
-
2791
- var migrationUtils_1 = __webpack_require__(1);
2792
-
1224
+ // src/visualizations/punchcard.ts
2793
1225
  var defaultContext = {
2794
1226
  bubbleColorConfig: {
2795
- colors: ['rgba(123,86,219,0.4)', 'rgba(123,86,219,1)']
1227
+ colors: ["rgba(123,86,219,0.4)", "rgba(123,86,219,1)"]
2796
1228
  }
2797
1229
  };
2798
- var optionsToRename = {
2799
- showBubbleLabels: 'bubbleLabelDisplay',
2800
- bubbleScale: 'bubbleSizeMethod',
2801
- isBubbleSizeDynamic: 'showDynamicBubbleSize',
2802
- maxBubbleRadius: 'bubbleRadiusMax',
2803
- minBubbleRadius: 'bubbleRadiusMin',
2804
- maxBubbleSize: 'bubbleSizeMax',
2805
- minBubbleSize: 'bubbleSizeMin',
2806
- showLegend: 'legendDisplay',
2807
- useDefaultSort: 'showDefaultSort'
1230
+ var optionsToRename5 = {
1231
+ showBubbleLabels: "bubbleLabelDisplay",
1232
+ bubbleScale: "bubbleSizeMethod",
1233
+ isBubbleSizeDynamic: "showDynamicBubbleSize",
1234
+ maxBubbleRadius: "bubbleRadiusMax",
1235
+ minBubbleRadius: "bubbleRadiusMin",
1236
+ maxBubbleSize: "bubbleSizeMax",
1237
+ minBubbleSize: "bubbleSizeMin",
1238
+ showLegend: "legendDisplay",
1239
+ useDefaultSort: "showDefaultSort"
2808
1240
  };
2809
-
2810
- var consolidateLegendDisplay = function consolidateLegendDisplay(vizOptions) {
1241
+ var consolidateLegendDisplay = (vizOptions) => {
2811
1242
  if (!vizOptions) {
2812
1243
  return;
2813
1244
  }
2814
-
2815
- var options = vizOptions;
2816
-
1245
+ const options = vizOptions;
2817
1246
  if (options.legendDisplay) {
2818
- options.legendDisplay = 'right';
1247
+ options.legendDisplay = "right";
2819
1248
  } else if (options.legendDisplay === false) {
2820
- options.legendDisplay = 'off'; // legenddisplay set explicitly to false
1249
+ options.legendDisplay = "off";
2821
1250
  }
2822
1251
  };
2823
-
2824
- var consolidateBubbleLabelDisplay = function consolidateBubbleLabelDisplay(vizOptions) {
1252
+ var consolidateBubbleLabelDisplay = (vizOptions) => {
2825
1253
  if (!vizOptions) {
2826
1254
  return;
2827
1255
  }
2828
-
2829
- var options = vizOptions;
2830
-
2831
- if (options.bubbleLabelDisplay === 'none') {
2832
- options.bubbleLabelDisplay = 'off';
1256
+ const options = vizOptions;
1257
+ if (options.bubbleLabelDisplay === "none") {
1258
+ options.bubbleLabelDisplay = "off";
2833
1259
  }
2834
- }; // Updates the first color of the bubbleColorConfig with the minBubbleColorIntensity
2835
-
2836
-
2837
- var convertGradientConfig = function convertGradientConfig(minBubbleColorIntensity, defaultBubbleColorConfig) {
2838
- if (!defaultBubbleColorConfig || !defaultBubbleColorConfig.colors || !defaultBubbleColorConfig.colors[0] || typeof minBubbleColorIntensity !== 'number') {
1260
+ };
1261
+ var convertGradientConfig = (minBubbleColorIntensity, defaultBubbleColorConfig) => {
1262
+ if (!defaultBubbleColorConfig || !defaultBubbleColorConfig.colors || !defaultBubbleColorConfig.colors[0] || typeof minBubbleColorIntensity !== "number") {
2839
1263
  return null;
2840
1264
  }
2841
-
2842
- var firstColor = defaultBubbleColorConfig.colors[0];
2843
- var firstColorUpdated = "".concat(firstColor.substring(0, firstColor.lastIndexOf(',')), ",").concat(minBubbleColorIntensity, ")");
2844
-
2845
- var colors = _toConsumableArray(defaultBubbleColorConfig.colors);
2846
-
1265
+ const firstColor = defaultBubbleColorConfig.colors[0];
1266
+ const firstColorUpdated = `${firstColor.substring(
1267
+ 0,
1268
+ firstColor.lastIndexOf(",")
1269
+ )},${minBubbleColorIntensity})`;
1270
+ const colors = [...defaultBubbleColorConfig.colors];
2847
1271
  colors[0] = firstColorUpdated;
2848
- var bubbleColorConfigUpdated = Object.assign(Object.assign({}, defaultBubbleColorConfig), {
2849
- colors: colors
2850
- });
1272
+ const bubbleColorConfigUpdated = __spreadProps(__spreadValues({}, defaultBubbleColorConfig), { colors });
2851
1273
  return bubbleColorConfigUpdated;
2852
1274
  };
2853
-
2854
- var convertColorModeOption = function convertColorModeOption(visualizationDefinition) {
2855
- var visualizationDef = visualizationDefinition;
2856
-
1275
+ var convertColorModeOption = (visualizationDefinition) => {
1276
+ const visualizationDef = visualizationDefinition;
2857
1277
  if (!visualizationDef || !visualizationDef.options) {
2858
1278
  return;
2859
- } // Rename the colorMode option from 'sequential' to 'dynamic' if specified
2860
-
2861
-
2862
- if (visualizationDef.options.colorMode === 'sequential') {
2863
- visualizationDef.options.colorMode = 'dynamic';
2864
- } // If no colorMode was specified the default in viz.punchcard used to be 'categorical'.
2865
- // But in splunk.punchcard default is 'dynamic', we need to preserve the original default.
2866
- // Set colorMode to 'categorical' if no colorMode was specified in viz
2867
-
2868
-
2869
- if (!visualizationDef.options.colorMode) {
2870
- visualizationDef.options.colorMode = 'categorical';
2871
1279
  }
2872
-
2873
- var minBubbleColorIntensity = visualizationDef.options.minBubbleColorIntensity; // If there is no category option set or if the colorMode is not categorical, then the colorMode will to 'dynamic'
2874
- // In both cases we need to update the gradient config bubbleColorConfig with the minBubbleColorIntensity for first color
2875
-
2876
- if ((!visualizationDef.options.category || visualizationDef.options.colorMode !== 'categorical') && minBubbleColorIntensity && typeof minBubbleColorIntensity === 'number') {
2877
- var bubbleColorConfig = convertGradientConfig(minBubbleColorIntensity, defaultContext.bubbleColorConfig);
2878
-
1280
+ if (visualizationDef.options.colorMode === "sequential") {
1281
+ visualizationDef.options.colorMode = "dynamic";
1282
+ }
1283
+ if (!visualizationDef.options.colorMode) {
1284
+ visualizationDef.options.colorMode = "categorical";
1285
+ }
1286
+ const { minBubbleColorIntensity } = visualizationDef.options;
1287
+ if ((!visualizationDef.options.category || visualizationDef.options.colorMode !== "categorical") && minBubbleColorIntensity && typeof minBubbleColorIntensity === "number") {
1288
+ const bubbleColorConfig = convertGradientConfig(
1289
+ minBubbleColorIntensity,
1290
+ defaultContext.bubbleColorConfig
1291
+ );
2879
1292
  if (bubbleColorConfig) {
2880
- visualizationDef.context = Object.assign(Object.assign({}, visualizationDef.context), {
2881
- bubbleColorConfig: bubbleColorConfig
2882
- });
1293
+ visualizationDef.context = __spreadProps(__spreadValues({}, visualizationDef.context), { bubbleColorConfig });
2883
1294
  }
2884
1295
  }
2885
1296
  };
2886
-
2887
- var migrateVizToSplunkPunchcard = function migrateVizToSplunkPunchcard(vizDefinition) {
2888
- var _vizDefinition$option = vizDefinition.options,
2889
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2890
- _vizDefinition$encodi = vizDefinition.encoding,
2891
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2892
- otherDefinitionParts = __rest(vizDefinition, ["options", "encoding"]);
2893
-
2894
- var migratedVisualization = Object.assign(Object.assign({
2895
- options: options
2896
- }, otherDefinitionParts), {
2897
- type: 'splunk.punchcard',
2898
- context: {}
2899
- });
2900
-
2901
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2902
- dataOptions = _ref.options,
2903
- dataContext = _ref.context; // perform any option renames
2904
-
2905
-
2906
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(migratedVisualization.options, optionsToRename);
1297
+ var migrateVizToSplunkPunchcard = (vizDefinition) => {
1298
+ const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
1299
+ const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.punchcard", context: {} });
1300
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
1301
+ encoding
1302
+ );
1303
+ const renamedOptions = renameVizOptions(migratedVisualization.options, optionsToRename5);
2907
1304
  consolidateLegendDisplay(renamedOptions);
2908
1305
  consolidateBubbleLabelDisplay(renamedOptions);
2909
- migratedVisualization.options = Object.assign(Object.assign({}, renamedOptions), dataOptions);
1306
+ migratedVisualization.options = __spreadValues(__spreadValues({}, renamedOptions), dataOptions);
2910
1307
  migratedVisualization.context = dataContext;
2911
- convertColorModeOption(migratedVisualization); // remove invalid options using the optionsSchema for splunk.punchcard as reference
2912
-
2913
- (0, migrationUtils_1.removeInvalidOptions)(migratedVisualization.options, visualization_schemas_1.punchcardOptionsSchema);
1308
+ convertColorModeOption(migratedVisualization);
1309
+ removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.punchcardOptionsSchema);
2914
1310
  return migratedVisualization;
2915
1311
  };
2916
1312
 
2917
- exports.migrateVizToSplunkPunchcard = migrateVizToSplunkPunchcard;
2918
-
2919
- /***/ }),
2920
- /* 37 */
2921
- /***/ (function(module, exports, __webpack_require__) {
2922
-
2923
- "use strict";
2924
-
2925
-
2926
- var __rest = this && this.__rest || function (s, e) {
2927
- var t = {};
2928
-
2929
- for (var p in s) {
2930
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2931
- }
2932
-
2933
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2934
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2935
- }
2936
- return t;
2937
- };
2938
-
2939
- Object.defineProperty(exports, "__esModule", {
2940
- value: true
2941
- });
2942
- exports.migrateVizToSplunkMapChoropleth = exports.defaultEmptyAreaColor = exports.defaultStrokeColor = void 0;
2943
-
2944
- var visualization_schemas_1 = __webpack_require__(0);
2945
-
2946
- var encoding_1 = __webpack_require__(2);
2947
-
2948
- var migrationUtils_1 = __webpack_require__(1);
2949
-
2950
- var optionRenames = {
2951
- fillColor: 'choroplethEmptyAreaColor',
2952
- strokeColor: 'choroplethStrokeColor',
2953
- featureId: 'areaIds',
2954
- fill: 'dataColors',
2955
- value: 'areaValues'
1313
+ // src/visualizations/choropleth.ts
1314
+ var optionRenames8 = {
1315
+ fillColor: "choroplethEmptyAreaColor",
1316
+ strokeColor: "choroplethStrokeColor",
1317
+ featureId: "areaIds",
1318
+ fill: "dataColors",
1319
+ value: "areaValues"
2956
1320
  };
2957
- var defaultContextChanges = {
1321
+ var defaultContextChanges2 = {
2958
1322
  fillGradientContext: {
2959
- colors: '> themes.defaultGradientMigrationConfig'
1323
+ colors: "> themes.defaultGradientMigrationConfig"
2960
1324
  }
2961
1325
  };
2962
- exports.defaultStrokeColor = '#689C8D';
2963
- exports.defaultEmptyAreaColor = '#EAEFF2';
2964
-
2965
- var migrateVizToSplunkMapChoropleth = function migrateVizToSplunkMapChoropleth(vizDefinition) {
2966
- var _vizDefinition$encodi = vizDefinition.encoding,
2967
- encoding = _vizDefinition$encodi === void 0 ? {} : _vizDefinition$encodi,
2968
- _vizDefinition$option = vizDefinition.options,
2969
- options = _vizDefinition$option === void 0 ? {} : _vizDefinition$option,
2970
- otherDefinitionParts = __rest(vizDefinition, ["encoding", "options"]);
2971
-
2972
- var migratedDefinition = Object.assign(Object.assign({}, otherDefinitionParts), {
2973
- type: 'splunk.map',
1326
+ var defaultStrokeColor = "#689C8D";
1327
+ var defaultEmptyAreaColor = "#EAEFF2";
1328
+ var migrateVizToSplunkMapChoropleth = (vizDefinition) => {
1329
+ const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
1330
+ const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
1331
+ type: "splunk.map",
2974
1332
  options: {},
2975
1333
  context: {}
2976
1334
  });
2977
-
2978
- var _ref = (0, encoding_1.encodingToDynamicOptionsDSL)(encoding),
2979
- dataOptions = _ref.options,
2980
- dataContext = _ref.context;
2981
-
2982
- var dynamicOptions = (0, migrationUtils_1.renameVizOptions)(dataOptions, optionRenames);
2983
- var renamedOptions = (0, migrationUtils_1.renameVizOptions)(options, optionRenames);
2984
-
2985
- if (!('dataColors' in dynamicOptions)) {
1335
+ const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
1336
+ encoding
1337
+ );
1338
+ const dynamicOptions = renameVizOptions(dataOptions, optionRenames8);
1339
+ const renamedOptions = renameVizOptions(options, optionRenames8);
1340
+ if (!("dataColors" in dynamicOptions)) {
2986
1341
  Object.assign(dynamicOptions, {
2987
- dataColors: '> areaValues | gradient(fillGradientContext)'
1342
+ dataColors: "> areaValues | gradient(fillGradientContext)"
2988
1343
  });
2989
1344
  }
2990
-
2991
- var choroplethEmptyAreaColor = renamedOptions.choroplethEmptyAreaColor,
2992
- choroplethStrokeColor = renamedOptions.choroplethStrokeColor;
2993
- var source = renamedOptions.source;
2994
- var layerOptions = ['choroplethEmptyAreaColor', 'choroplethStrokeColor', 'source'];
2995
- var renamedOptionsFiltered = Object.keys(renamedOptions).filter(function (key) {
2996
- return !layerOptions.includes(key);
2997
- }).reduce(function (obj, key) {
2998
- /* eslint-disable-next-line no-param-reassign */
1345
+ let { choroplethEmptyAreaColor, choroplethStrokeColor } = renamedOptions;
1346
+ const { source } = renamedOptions;
1347
+ const layerOptions = ["choroplethEmptyAreaColor", "choroplethStrokeColor", "source"];
1348
+ const renamedOptionsFiltered = Object.keys(renamedOptions).filter((key) => !layerOptions.includes(key)).reduce((obj, key) => {
2999
1349
  obj[key] = renamedOptions[key];
3000
1350
  return obj;
3001
1351
  }, {});
3002
- /* migrate default strokeColor in viz.geojson to either the backgroundColor if configured and non-transparent or defaultBackgroundColor in splunk.map */
3003
-
3004
- if (choroplethStrokeColor === exports.defaultStrokeColor && choroplethEmptyAreaColor !== 'transparent') {
3005
- if ('backgroundColor' in renamedOptionsFiltered) {
3006
- /* eslint-disable-next-line dot-notation */
3007
- if (renamedOptionsFiltered['backgroundColor'] !== 'transparent') {
3008
- /* eslint-disable-next-line dot-notation */
3009
- choroplethStrokeColor = renamedOptionsFiltered['backgroundColor'];
1352
+ if (choroplethStrokeColor === defaultStrokeColor && choroplethEmptyAreaColor !== "transparent") {
1353
+ if ("backgroundColor" in renamedOptionsFiltered) {
1354
+ if (renamedOptionsFiltered["backgroundColor"] !== "transparent") {
1355
+ choroplethStrokeColor = renamedOptionsFiltered["backgroundColor"];
3010
1356
  } else {
3011
- choroplethStrokeColor = '> themes.defaultBackgroundColor';
1357
+ choroplethStrokeColor = "> themes.defaultBackgroundColor";
3012
1358
  }
3013
1359
  } else {
3014
- choroplethStrokeColor = '> themes.defaultBackgroundColor';
1360
+ choroplethStrokeColor = "> themes.defaultBackgroundColor";
3015
1361
  }
3016
1362
  }
3017
-
3018
- if (choroplethEmptyAreaColor === exports.defaultEmptyAreaColor) {
3019
- choroplethEmptyAreaColor = '> themes.defaultChoroplethEmptyAreaColor';
3020
- } // update migrated options and context
3021
-
3022
-
3023
- migratedDefinition.options = Object.assign(Object.assign({}, renamedOptionsFiltered), {
3024
- layers: [Object.assign(Object.assign({
3025
- type: 'choropleth',
3026
- source: source
3027
- }, dynamicOptions), {
3028
- choroplethEmptyAreaColor: choroplethEmptyAreaColor,
3029
- choroplethStrokeColor: choroplethStrokeColor,
3030
- choroplethOpacity: 1.0
3031
- })],
1363
+ if (choroplethEmptyAreaColor === defaultEmptyAreaColor) {
1364
+ choroplethEmptyAreaColor = "> themes.defaultChoroplethEmptyAreaColor";
1365
+ }
1366
+ migratedDefinition.options = __spreadProps(__spreadValues({}, renamedOptionsFiltered), {
1367
+ layers: [
1368
+ __spreadProps(__spreadValues({
1369
+ type: "choropleth",
1370
+ source
1371
+ }, dynamicOptions), {
1372
+ choroplethEmptyAreaColor,
1373
+ choroplethStrokeColor,
1374
+ choroplethOpacity: 1
1375
+ })
1376
+ ],
3032
1377
  showScale: false,
3033
1378
  showBaseLayer: false,
3034
1379
  showZoomControls: false
3035
1380
  });
3036
-
3037
- if (vizDefinition.type === 'viz.geojson.us') {
1381
+ if (vizDefinition.type === "viz.geojson.us") {
3038
1382
  migratedDefinition.options.center = [39.83, -97];
3039
1383
  migratedDefinition.options.zoom = 3;
3040
1384
  } else {
3041
1385
  migratedDefinition.options.center = [46.56, 10.35];
3042
1386
  migratedDefinition.options.zoom = 0;
3043
1387
  }
3044
-
3045
- migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges;
3046
-
1388
+ migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges2;
3047
1389
  if (JSON.stringify(dataContext) === JSON.stringify({
3048
1390
  fillGradientContext: {}
3049
1391
  })) {
3050
1392
  Object.assign(migratedDefinition, {
3051
- context: defaultContextChanges
1393
+ context: defaultContextChanges2
3052
1394
  });
3053
1395
  }
3054
-
3055
- (0, migrationUtils_1.removeInvalidOptions)(migratedDefinition.options, visualization_schemas_1.mapOptionsSchema);
1396
+ removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.mapOptionsSchema);
3056
1397
  return migratedDefinition;
3057
1398
  };
3058
1399
 
3059
- exports.migrateVizToSplunkMapChoropleth = migrateVizToSplunkMapChoropleth;
3060
-
3061
- /***/ })
3062
- /******/ ]);
3063
- //# sourceMappingURL=index.js.map
1400
+ // src/migrate.ts
1401
+ var supportedMigrations = {
1402
+ "viz.area": {
1403
+ "splunk.area": migrateVizToSplunkArea
1404
+ },
1405
+ "viz.bar": {
1406
+ "splunk.bar": migrateVizToSplunkBar
1407
+ },
1408
+ "viz.bubble": {
1409
+ "splunk.bubble": migrateVizToSplunkBubble
1410
+ },
1411
+ "viz.column": {
1412
+ "splunk.column": migrateVizToSplunkColumn
1413
+ },
1414
+ "viz.choropleth.svg": {
1415
+ "splunk.choropleth.svg": migrateVizToSplunkChoroplethSvg
1416
+ },
1417
+ "viz.geojson.us": {
1418
+ "splunk.map": migrateVizToSplunkMapChoropleth
1419
+ },
1420
+ "viz.geojson.world": {
1421
+ "splunk.map": migrateVizToSplunkMapChoropleth
1422
+ },
1423
+ "viz.ellipse": {
1424
+ "splunk.ellipse": migrateVizToSplunkEllipse
1425
+ },
1426
+ "viz.fillergauge": {
1427
+ "splunk.fillergauge": migrateVizToSplunkFillerGauge
1428
+ },
1429
+ "viz.line": {
1430
+ "splunk.line": migrateVizToSplunkLine
1431
+ },
1432
+ "viz.img": {
1433
+ "splunk.image": migrateVizToSplunkImage
1434
+ },
1435
+ "viz.markdown": {
1436
+ "splunk.markdown": migrateVizToSplunkMarkdown
1437
+ },
1438
+ "viz.markergauge": {
1439
+ "splunk.markergauge": migrateVizToSplunkMarkerGauge
1440
+ },
1441
+ "viz.pie": {
1442
+ "splunk.pie": migrateVizToSplunkPie
1443
+ },
1444
+ "viz.rectangle": {
1445
+ "splunk.rectangle": migrateVizToSplunkRectangle
1446
+ },
1447
+ "viz.singlevalue": {
1448
+ "splunk.singlevalue": migrateVizToSplunkSingleValue
1449
+ },
1450
+ "viz.singlevalueicon": {
1451
+ "splunk.singlevalueicon": migrateVizToSplunkSingleValueIcon
1452
+ },
1453
+ "viz.singlevalueradial": {
1454
+ "splunk.singlevalueradial": migrateVizToSplunkSingleValueRadial
1455
+ },
1456
+ "viz.scatter": {
1457
+ "splunk.scatter": migrateVizToSplunkScatter
1458
+ },
1459
+ "viz.table": {
1460
+ "splunk.table": migrateVizToSplunkTable
1461
+ },
1462
+ "viz.text": {
1463
+ "splunk.markdown": migrateVizTextToSplunkMarkdown
1464
+ },
1465
+ "viz.punchcard": {
1466
+ "splunk.punchcard": migrateVizToSplunkPunchcard
1467
+ }
1468
+ };
1469
+ var inferToType = (typeFromDefinition) => {
1470
+ if (typeFromDefinition === "viz.img") {
1471
+ return "splunk.image";
1472
+ }
1473
+ if (typeFromDefinition === "viz.text") {
1474
+ return "splunk.markdown";
1475
+ }
1476
+ if (typeFromDefinition === "viz.geojson.us" || typeFromDefinition === "viz.geojson.world") {
1477
+ return "splunk.map";
1478
+ }
1479
+ return typeFromDefinition.replace(/^viz\./, "splunk.");
1480
+ };
1481
+ var migrate = ({ definition, toType: toTypeFromParams }) => {
1482
+ var _a;
1483
+ const toType = toTypeFromParams != null ? toTypeFromParams : inferToType(definition.type);
1484
+ if (!((_a = supportedMigrations == null ? void 0 : supportedMigrations[definition == null ? void 0 : definition.type]) == null ? void 0 : _a[toType])) {
1485
+ throw new Error("Migration currently not supported");
1486
+ }
1487
+ return supportedMigrations[definition.type][toType](definition);
1488
+ };
1489
+ var canMigrate = ({ fromType, toType }) => {
1490
+ var _a;
1491
+ if ((_a = supportedMigrations == null ? void 0 : supportedMigrations[fromType]) == null ? void 0 : _a[toType]) {
1492
+ return true;
1493
+ }
1494
+ return false;
1495
+ };
1496
+ //# sourceMappingURL=index.js.map