@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 +1156 -2723
- package/index.js.map +7 -1
- package/migrate.js +1495 -0
- package/migrate.js.map +7 -0
- package/package.json +8 -15
- package/tsconfig.json +3 -1
- package/types/index.d.ts +1 -0
package/migrate.js
ADDED
|
@@ -0,0 +1,1495 @@
|
|
|
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/migrate.ts
|
|
63
|
+
var migrate_exports = {};
|
|
64
|
+
__export(migrate_exports, {
|
|
65
|
+
canMigrate: () => canMigrate,
|
|
66
|
+
inferToType: () => inferToType,
|
|
67
|
+
migrate: () => migrate
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(migrate_exports);
|
|
70
|
+
|
|
71
|
+
// esm-externals:@splunk/visualization-schemas
|
|
72
|
+
var visualization_schemas_exports = {};
|
|
73
|
+
__export(visualization_schemas_exports, {
|
|
74
|
+
default: () => visualization_schemas_default
|
|
75
|
+
});
|
|
76
|
+
var defaultImport = __toESM(require("@splunk/visualization-schemas"));
|
|
77
|
+
__reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
|
|
78
|
+
var visualization_schemas_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
79
|
+
|
|
80
|
+
// esm-externals:@splunk/visualization-encoding/utils/parserUtils
|
|
81
|
+
var parserUtils_exports = {};
|
|
82
|
+
__export(parserUtils_exports, {
|
|
83
|
+
default: () => parserUtils_default
|
|
84
|
+
});
|
|
85
|
+
var defaultImport2 = __toESM(require("@splunk/visualization-encoding/utils/parserUtils"));
|
|
86
|
+
__reExport(parserUtils_exports, require("@splunk/visualization-encoding/utils/parserUtils"));
|
|
87
|
+
var parserUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
88
|
+
|
|
89
|
+
// src/encoding/encoding.ts
|
|
90
|
+
var indexBasedRegx = /^[A-Za-z0-9_]+\[.*\].*$/;
|
|
91
|
+
var nameBasedRegx = /^[A-Za-z0-9_]+\..*$/;
|
|
92
|
+
var isIndexBasedReference = (ref) => indexBasedRegx.test(ref);
|
|
93
|
+
var isNameBasedReference = (ref) => nameBasedRegx.test(ref);
|
|
94
|
+
var convertFormatterToDSL = (fieldReference, key, translatedValue) => {
|
|
95
|
+
var _a, _b, _c, _d, _e, _f;
|
|
96
|
+
switch ((_a = fieldReference == null ? void 0 : fieldReference.format) == null ? void 0 : _a.type) {
|
|
97
|
+
case "gradient":
|
|
98
|
+
return {
|
|
99
|
+
contextConfig: __spreadValues(__spreadValues({}, Array.isArray((_b = fieldReference.format) == null ? void 0 : _b.ranges) && {
|
|
100
|
+
stops: [...fieldReference.format.ranges]
|
|
101
|
+
}), Array.isArray((_c = fieldReference.format) == null ? void 0 : _c.values) && {
|
|
102
|
+
colors: [...fieldReference.format.values]
|
|
103
|
+
}),
|
|
104
|
+
contextKey: `${key}GradientContext`,
|
|
105
|
+
dsl: `${translatedValue} | gradient(${key}GradientContext)`
|
|
106
|
+
};
|
|
107
|
+
case "rangevalue": {
|
|
108
|
+
const contextKey = `${key}RangeValueContext`;
|
|
109
|
+
return {
|
|
110
|
+
contextConfig: ((_d = fieldReference.format) == null ? void 0 : _d.ranges) || [],
|
|
111
|
+
contextKey,
|
|
112
|
+
dsl: `${translatedValue} | rangeValue(${contextKey})`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
case "matchvalue": {
|
|
116
|
+
const defaultValue = (_e = fieldReference.format) == null ? void 0 : _e.defaultValue;
|
|
117
|
+
const matchValueContextKey = `${key}MatchValueContext`;
|
|
118
|
+
return {
|
|
119
|
+
contextConfig: ((_f = fieldReference.format) == null ? void 0 : _f.matches) || [],
|
|
120
|
+
contextKey: matchValueContextKey,
|
|
121
|
+
dsl: `${translatedValue} | matchValue(${matchValueContextKey}${defaultValue !== null && defaultValue !== void 0 ? `, ${typeof defaultValue === "string" ? `"${defaultValue}"` : defaultValue}` : ""})`
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
var translateArrayFormatDataReference = (encodingDataReference) => {
|
|
130
|
+
if (encodingDataReference.length === 0) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const allIndexBased = encodingDataReference.every(isIndexBasedReference);
|
|
134
|
+
const allNameBased = encodingDataReference.every(isNameBasedReference);
|
|
135
|
+
if (allIndexBased) {
|
|
136
|
+
const { dataSourceName: dataSourceName2 } = (0, parserUtils_exports.parseIndexBasedFieldReference)(encodingDataReference[0]);
|
|
137
|
+
const indexesStr = encodingDataReference.map((ref) => {
|
|
138
|
+
var _a;
|
|
139
|
+
return (_a = (0, parserUtils_exports.parseIndexBasedFieldReference)(ref)) == null ? void 0 : _a.fieldIndex;
|
|
140
|
+
}).join(",");
|
|
141
|
+
return `> ${dataSourceName2} | frameBySeriesIndexes(${indexesStr})`;
|
|
142
|
+
}
|
|
143
|
+
if (allNameBased) {
|
|
144
|
+
const { dataSourceName: dataSourceName2 } = (0, parserUtils_exports.parseNameBasedFieldReference)(encodingDataReference[0]);
|
|
145
|
+
const namesStr = encodingDataReference.map((ref) => {
|
|
146
|
+
var _a;
|
|
147
|
+
return `"${(_a = (0, parserUtils_exports.parseNameBasedFieldReference)(ref)) == null ? void 0 : _a.fieldName}"`;
|
|
148
|
+
}).join(",");
|
|
149
|
+
return `> ${dataSourceName2} | frameBySeriesNames(${namesStr})`;
|
|
150
|
+
}
|
|
151
|
+
const firstEntry = encodingDataReference[0];
|
|
152
|
+
const { dataSourceName } = isIndexBasedReference(firstEntry) ? (0, parserUtils_exports.parseIndexBasedFieldReference)(firstEntry) : (0, parserUtils_exports.parseNameBasedFieldReference)(firstEntry);
|
|
153
|
+
const paramStr = encodingDataReference.map((ref) => {
|
|
154
|
+
var _a, _b;
|
|
155
|
+
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}"`;
|
|
156
|
+
}).join(",");
|
|
157
|
+
return `> ${dataSourceName} | frameBySeriesNamesOrIndexes(${paramStr})`;
|
|
158
|
+
};
|
|
159
|
+
var translateDataReference = (encodingDataReference) => {
|
|
160
|
+
if (encodingDataReference.indexOf("encoding.") === 0) {
|
|
161
|
+
return `> ${encodingDataReference.replace("encoding.", "")}`;
|
|
162
|
+
}
|
|
163
|
+
const isIndexBasedRef = isIndexBasedReference(encodingDataReference);
|
|
164
|
+
const isNameBasedRef = isNameBasedReference(encodingDataReference);
|
|
165
|
+
if (!isIndexBasedRef && !isNameBasedRef) {
|
|
166
|
+
console.warn("Unable to parse the encoding. Please verify the encoding format is correct");
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (isNameBasedRef) {
|
|
170
|
+
const { dataSourceName, fieldName, columnIndex } = (0, parserUtils_exports.parseNameBasedFieldReference)(
|
|
171
|
+
encodingDataReference
|
|
172
|
+
);
|
|
173
|
+
let returnString = `> ${dataSourceName} | seriesByName("${fieldName}")`;
|
|
174
|
+
if (columnIndex) {
|
|
175
|
+
returnString += ` | pointByIndex(${columnIndex})`;
|
|
176
|
+
}
|
|
177
|
+
return returnString;
|
|
178
|
+
}
|
|
179
|
+
if (isIndexBasedRef) {
|
|
180
|
+
const {
|
|
181
|
+
dataSourceName,
|
|
182
|
+
fieldIndex,
|
|
183
|
+
columnIndex,
|
|
184
|
+
isFieldIndexRange,
|
|
185
|
+
fromFieldIndex,
|
|
186
|
+
toFieldIndex
|
|
187
|
+
} = (0, parserUtils_exports.parseIndexBasedFieldReference)(encodingDataReference);
|
|
188
|
+
if (isFieldIndexRange) {
|
|
189
|
+
let dslToIndexString;
|
|
190
|
+
if (toFieldIndex === -1) {
|
|
191
|
+
dslToIndexString = "";
|
|
192
|
+
} else {
|
|
193
|
+
dslToIndexString = `,${toFieldIndex + 1}`;
|
|
194
|
+
}
|
|
195
|
+
return `> ${dataSourceName} | frameBySeriesIndexRange(${fromFieldIndex}${dslToIndexString})`;
|
|
196
|
+
}
|
|
197
|
+
let returnString = `> ${dataSourceName} | seriesByIndex(${fieldIndex})`;
|
|
198
|
+
if (columnIndex) {
|
|
199
|
+
returnString += ` | pointByIndex(${columnIndex})`;
|
|
200
|
+
}
|
|
201
|
+
return returnString;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
};
|
|
205
|
+
var encodingToDynamicOptionsDSL = (encoding) => {
|
|
206
|
+
const dynamicOptions = {
|
|
207
|
+
options: {},
|
|
208
|
+
context: {}
|
|
209
|
+
};
|
|
210
|
+
const translatedOptions = {};
|
|
211
|
+
const encodingObj = encoding != null ? encoding : {};
|
|
212
|
+
Object.keys(encodingObj).forEach((key) => {
|
|
213
|
+
const fieldReference = encoding[key];
|
|
214
|
+
let fieldReferenceStr = fieldReference;
|
|
215
|
+
if (typeof fieldReference === "object" && !Array.isArray(fieldReference)) {
|
|
216
|
+
const { field } = fieldReference;
|
|
217
|
+
if (field && !Array.isArray(field)) {
|
|
218
|
+
fieldReferenceStr = field;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
let translatedValue;
|
|
222
|
+
if (Array.isArray(fieldReference)) {
|
|
223
|
+
translatedValue = translateArrayFormatDataReference(fieldReference);
|
|
224
|
+
} else {
|
|
225
|
+
translatedValue = translateDataReference(fieldReferenceStr);
|
|
226
|
+
}
|
|
227
|
+
if (translatedValue) {
|
|
228
|
+
translatedOptions[key] = translatedValue;
|
|
229
|
+
const convertedFormatterObject = convertFormatterToDSL(
|
|
230
|
+
fieldReference,
|
|
231
|
+
key,
|
|
232
|
+
translatedValue
|
|
233
|
+
);
|
|
234
|
+
if (convertedFormatterObject) {
|
|
235
|
+
translatedOptions[key] = convertedFormatterObject.dsl;
|
|
236
|
+
dynamicOptions.context[convertedFormatterObject.contextKey] = convertedFormatterObject.contextConfig;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
dynamicOptions.options = translatedOptions;
|
|
241
|
+
return dynamicOptions;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// src/visualizations/splunk-charting.ts
|
|
245
|
+
var optionRenames = {
|
|
246
|
+
"axisTitleX.text": "xAxisTitleText",
|
|
247
|
+
"axisTitleY.text": "yAxisTitleText",
|
|
248
|
+
"axisTitleY2.text": "y2AxisTitleText",
|
|
249
|
+
"axisTitleX.visibility": "xAxisTitleVisibility",
|
|
250
|
+
"axisTitleY.visibility": "yAxisTitleVisibility",
|
|
251
|
+
"axisTitleY2.visibility": "y2AxisTitleVisibility",
|
|
252
|
+
"axisLabelsX.majorLabelStyle.rotation": "xAxisLabelRotation",
|
|
253
|
+
"axisLabelsX.majorLabelVisibility": "xAxisLabelVisibility",
|
|
254
|
+
"axisLabelsY.majorLabelVisibility": "yAxisLabelVisibility",
|
|
255
|
+
"axisLabelsY2.majorLabelVisibility": "y2AxisLabelVisibility",
|
|
256
|
+
"axisLabelsX.majorTickVisibility": "xAxisMajorTickVisibility",
|
|
257
|
+
"axisLabelsY.majorTickVisibility": "yAxisMajorTickVisibility",
|
|
258
|
+
"axisLabelsY2.majorTickVisibility": "y2AxisMajorTickVisibility",
|
|
259
|
+
"axisLabelsX.minorTickVisibility": "xAxisMinorTickVisibility",
|
|
260
|
+
"axisLabelsY.minorTickVisibility": "yAxisMinorTickVisibility",
|
|
261
|
+
"axisLabelsY2.minorTickVisibility": "y2AxisMinorTickVisibility",
|
|
262
|
+
"axisLabelsX.majorTickSize": "xAxisMajorTickSize",
|
|
263
|
+
"axisLabelsY.majorTickSize": "yAxisMajorTickSize",
|
|
264
|
+
"axisLabelsY2.majorTickSize": "y2AxisMajorTickSize",
|
|
265
|
+
"axisLabelsX.minorTickSize": "xAxisMinorTickSize",
|
|
266
|
+
"axisLabelsY.minorTickSize": "yAxisMinorTickSize",
|
|
267
|
+
"axisLabelsY2.minorTickSize": "y2AxisMinorTickSize",
|
|
268
|
+
"axisLabelsX.majorUnit": "xAxisMajorTickInterval",
|
|
269
|
+
"axisLabelsY.majorUnit": "yAxisMajorTickInterval",
|
|
270
|
+
"axisLabelsY2.majorUnit": "y2AxisMajorTickInterval",
|
|
271
|
+
"axisX.abbreviation": "xAxisAbbreviation",
|
|
272
|
+
"axisY.abbreviation": "yAxisAbbreviation",
|
|
273
|
+
"axisY2.abbreviation": "y2AxisAbbreviation",
|
|
274
|
+
"axisLabelsX.integerUnits": "showRoundedXAxisLabels",
|
|
275
|
+
"axisLabelsY2.integerUnits": "showRoundedY2AxisLabels",
|
|
276
|
+
"axisLabelsX.maxLabelParts": "xAxisMaxLabelParts",
|
|
277
|
+
"axisLabelsX.axisVisibility": "xAxisLineVisibility",
|
|
278
|
+
"axisLabelsY.axisVisibility": "yAxisLineVisibility",
|
|
279
|
+
"axisLabelsY2.axisVisibility": "y2AxisLineVisibility",
|
|
280
|
+
"gridLinesX.showMajorLines": "showXMajorGridLines",
|
|
281
|
+
"gridLinesY.showMajorLines": "showYMajorGridLines",
|
|
282
|
+
"gridLinesX.showMinorLines": "showXMinorGridLines",
|
|
283
|
+
"gridLinesY.showMinorLines": "showYMinorGridLines",
|
|
284
|
+
"gridLinesY2.showMajorLines": "showY2MajorGridLines",
|
|
285
|
+
"gridLinesY2.showMinorLines": "showY2MinorGridLines",
|
|
286
|
+
"axisX.scale": "xAxisScale",
|
|
287
|
+
"axisY.scale": "yAxisScale",
|
|
288
|
+
"axisY2.scale": "y2AxisScale",
|
|
289
|
+
"axisX.maximumNumber": "xAxisMax",
|
|
290
|
+
"axisY.maximumNumber": "yAxisMax",
|
|
291
|
+
"axisY2.maximumNumber": "y2AxisMax",
|
|
292
|
+
"axisX.minimumNumber": "xAxisMin",
|
|
293
|
+
"axisY.minimumNumber": "yAxisMin",
|
|
294
|
+
"axisY2.minimumNumber": "y2AxisMin",
|
|
295
|
+
"axisX.includeZero": "showXAxisWithZero",
|
|
296
|
+
"axisY.includeZero": "showYAxisWithZero",
|
|
297
|
+
"axisY2.includeZero": "showY2AxisWithZero",
|
|
298
|
+
"axisLabelsX.extendsAxisRange": "showXAxisExtendedRange",
|
|
299
|
+
"axisLabelsY.extendsAxisRange": "showYAxisExtendedRange",
|
|
300
|
+
"layout.splitSeries": "showSplitSeries",
|
|
301
|
+
"layout.splitSeries.allowIndependentYRanges": "showIndependentYRanges",
|
|
302
|
+
"axisY2.enabled": "showOverlayY2Axis",
|
|
303
|
+
"axisY2.fields": "y2Fields",
|
|
304
|
+
"chart.overlayFields": "overlayFields",
|
|
305
|
+
"legend.labels": "legendLabels",
|
|
306
|
+
"legend.labelStyle.overflowMode": "legendTruncation",
|
|
307
|
+
"legend.mode": "legendMode",
|
|
308
|
+
"legend.placement": "legendDisplay",
|
|
309
|
+
"chart.nullValueMode": "nullValueDisplay",
|
|
310
|
+
"chart.showDataLabels": "dataValuesDisplay",
|
|
311
|
+
fieldColors: "seriesColorsByField",
|
|
312
|
+
"chart.resultTruncationLimit": "resultLimit",
|
|
313
|
+
"chart.stackMode": "stackMode",
|
|
314
|
+
"chart.barSpacing": "barSpacing",
|
|
315
|
+
"chart.columnSpacing": "columnSpacing",
|
|
316
|
+
"chart.seriesSpacing": "seriesSpacing",
|
|
317
|
+
"chart.sliceCollapsingLabel": "collapseLabel",
|
|
318
|
+
"chart.sliceCollapsingThreshold": "collapseThreshold",
|
|
319
|
+
hasDonutHole: "showDonutHole",
|
|
320
|
+
// area specific mapped options
|
|
321
|
+
areaFillOpacity: "areaOpacity",
|
|
322
|
+
"chart.showLines": "showLines",
|
|
323
|
+
// bubble specific mapped options
|
|
324
|
+
"chart.bubbleMinimumSize": "bubbleSizeMin",
|
|
325
|
+
"chart.bubbleMaximumSize": "bubbleSizeMax",
|
|
326
|
+
"chart.bubbleSizeBy": "bubbleSizeMethod",
|
|
327
|
+
// line specific mapped options
|
|
328
|
+
fieldDashStyles: "lineDashStylesByField",
|
|
329
|
+
"chart.showMarkers": "markerDisplay",
|
|
330
|
+
// scatter-specific options
|
|
331
|
+
"chart.markerSize": "markerSize"
|
|
332
|
+
};
|
|
333
|
+
var visibilityEnumReplacements = {
|
|
334
|
+
visible: "show",
|
|
335
|
+
collapsed: "hide"
|
|
336
|
+
};
|
|
337
|
+
var modeEnumReplacements = {
|
|
338
|
+
none: "off"
|
|
339
|
+
};
|
|
340
|
+
var abbreviationEnumReplacements = {
|
|
341
|
+
none: "auto"
|
|
342
|
+
};
|
|
343
|
+
var enumReplacements = {
|
|
344
|
+
xAxisTitleVisibility: visibilityEnumReplacements,
|
|
345
|
+
yAxisTitleVisibility: visibilityEnumReplacements,
|
|
346
|
+
y2AxisTitleVisibility: visibilityEnumReplacements,
|
|
347
|
+
xAxisAbbreviation: modeEnumReplacements,
|
|
348
|
+
yAxisAbbreviation: abbreviationEnumReplacements,
|
|
349
|
+
y2AxisAbbreviation: abbreviationEnumReplacements,
|
|
350
|
+
dataValuesDisplay: modeEnumReplacements,
|
|
351
|
+
legendDisplay: modeEnumReplacements,
|
|
352
|
+
legendTruncation: {
|
|
353
|
+
ellipsisNone: "ellipsisOff"
|
|
354
|
+
},
|
|
355
|
+
stackMode: {
|
|
356
|
+
default: "auto"
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var splitValue = (oldValue) => Array.isArray(oldValue) ? oldValue : oldValue.split(",");
|
|
360
|
+
var parseObjects = (oldValue) => {
|
|
361
|
+
if (typeof oldValue === "object" && !Array.isArray(oldValue)) {
|
|
362
|
+
return oldValue;
|
|
363
|
+
}
|
|
364
|
+
let nuValue = {};
|
|
365
|
+
try {
|
|
366
|
+
nuValue = JSON.parse(oldValue);
|
|
367
|
+
} catch (e) {
|
|
368
|
+
}
|
|
369
|
+
return nuValue;
|
|
370
|
+
};
|
|
371
|
+
var otherValueReplacements = {
|
|
372
|
+
y2Fields: splitValue,
|
|
373
|
+
overlayFields: splitValue,
|
|
374
|
+
legendLabels: splitValue,
|
|
375
|
+
seriesColorsByField: parseObjects,
|
|
376
|
+
lineDashStylesByField: parseObjects,
|
|
377
|
+
/**
|
|
378
|
+
* the original markerDisplay was only exposed as `chart.showMarkers`
|
|
379
|
+
* setting chart.showMarkers to true is the equivalent of `markerDisplay: 'outlined'`
|
|
380
|
+
*/
|
|
381
|
+
markerDisplay: (oldValue) => {
|
|
382
|
+
if (oldValue === false) return "off";
|
|
383
|
+
if (oldValue === true) return "outlined";
|
|
384
|
+
return oldValue;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var migrateChartingOptions = (options) => {
|
|
388
|
+
const migratedOptions = {};
|
|
389
|
+
Object.keys(options).forEach((key) => {
|
|
390
|
+
var _a, _b, _c;
|
|
391
|
+
const value = options[key];
|
|
392
|
+
const updatedKey = (_a = optionRenames[key]) != null ? _a : key;
|
|
393
|
+
let updatedValue = (_c = (_b = enumReplacements == null ? void 0 : enumReplacements[updatedKey]) == null ? void 0 : _b[value]) != null ? _c : value;
|
|
394
|
+
if (otherValueReplacements[updatedKey]) {
|
|
395
|
+
updatedValue = otherValueReplacements[updatedKey](updatedValue);
|
|
396
|
+
}
|
|
397
|
+
migratedOptions[updatedKey] = updatedValue;
|
|
398
|
+
});
|
|
399
|
+
return migratedOptions;
|
|
400
|
+
};
|
|
401
|
+
var migrateBaseChartingVizDefinition = ({
|
|
402
|
+
defaultChanges: defaultChanges10,
|
|
403
|
+
validOptions: validOptions22,
|
|
404
|
+
vizDefinition,
|
|
405
|
+
vizType
|
|
406
|
+
}) => {
|
|
407
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
408
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
409
|
+
type: vizType,
|
|
410
|
+
options: {},
|
|
411
|
+
context: {}
|
|
412
|
+
});
|
|
413
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
414
|
+
encoding
|
|
415
|
+
);
|
|
416
|
+
const migratedOptions = __spreadValues(__spreadValues(__spreadValues({}, defaultChanges10), migrateChartingOptions(options)), dataOptions);
|
|
417
|
+
Object.keys(migratedOptions).forEach((key) => {
|
|
418
|
+
if (!validOptions22[key]) {
|
|
419
|
+
delete migratedOptions[key];
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
migratedDefinition.options = migratedOptions;
|
|
423
|
+
migratedDefinition.context = dataContext;
|
|
424
|
+
return migratedDefinition;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
// src/visualizations/area.ts
|
|
428
|
+
var defaultChanges = {
|
|
429
|
+
yAxisAbbreviation: "off",
|
|
430
|
+
y2AxisAbbreviation: "off",
|
|
431
|
+
showRoundedY2AxisLabels: false,
|
|
432
|
+
legendTruncation: "ellipsisMiddle",
|
|
433
|
+
showY2MajorGridLines: true
|
|
434
|
+
};
|
|
435
|
+
var migrateVizToSplunkArea = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
436
|
+
defaultChanges,
|
|
437
|
+
validOptions: visualization_schemas_exports.areaOptionsSchema,
|
|
438
|
+
vizDefinition,
|
|
439
|
+
vizType: "splunk.area"
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// src/visualizations/bar.ts
|
|
443
|
+
var defaultChanges2 = {
|
|
444
|
+
yAxisAbbreviation: "off",
|
|
445
|
+
y2AxisAbbreviation: "off",
|
|
446
|
+
showRoundedY2AxisLabels: false,
|
|
447
|
+
legendTruncation: "ellipsisMiddle",
|
|
448
|
+
showY2MajorGridLines: true
|
|
449
|
+
};
|
|
450
|
+
var migrateVizToSplunkBar = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
451
|
+
defaultChanges: defaultChanges2,
|
|
452
|
+
validOptions: visualization_schemas_exports.barOptionsSchema,
|
|
453
|
+
vizDefinition,
|
|
454
|
+
vizType: "splunk.bar"
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// src/visualizations/bubble.ts
|
|
458
|
+
var defaultChanges3 = {
|
|
459
|
+
yAxisAbbreviation: "off",
|
|
460
|
+
legendTruncation: "ellipsisMiddle"
|
|
461
|
+
};
|
|
462
|
+
var migrateVizToSplunkBubble = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
463
|
+
defaultChanges: defaultChanges3,
|
|
464
|
+
validOptions: visualization_schemas_exports.bubbleOptionsSchema,
|
|
465
|
+
vizDefinition,
|
|
466
|
+
vizType: "splunk.bubble"
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// esm-externals:@splunk/visualization-encoding/utils/dsl
|
|
470
|
+
var dsl_exports = {};
|
|
471
|
+
__export(dsl_exports, {
|
|
472
|
+
default: () => dsl_default
|
|
473
|
+
});
|
|
474
|
+
var defaultImport3 = __toESM(require("@splunk/visualization-encoding/utils/dsl"));
|
|
475
|
+
__reExport(dsl_exports, require("@splunk/visualization-encoding/utils/dsl"));
|
|
476
|
+
var dsl_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
477
|
+
|
|
478
|
+
// src/utils/migrationUtils.ts
|
|
479
|
+
var removeInvalidOptions = (currentOptions, validOptions22) => {
|
|
480
|
+
if (!currentOptions || !validOptions22) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const copiedCurrOptions = currentOptions;
|
|
484
|
+
Object.keys(copiedCurrOptions).forEach((key) => {
|
|
485
|
+
if (!(key in validOptions22)) {
|
|
486
|
+
delete copiedCurrOptions[key];
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
var renameVizOptions = (oldOptions, optionRenames9) => {
|
|
491
|
+
const updatedOptions = {};
|
|
492
|
+
if (!oldOptions) return {};
|
|
493
|
+
if (!optionRenames9) return oldOptions;
|
|
494
|
+
Object.entries(oldOptions).forEach(([oldOptName, val]) => {
|
|
495
|
+
var _a;
|
|
496
|
+
const optionName = (_a = optionRenames9[oldOptName]) != null ? _a : oldOptName;
|
|
497
|
+
updatedOptions[optionName] = val;
|
|
498
|
+
});
|
|
499
|
+
return updatedOptions;
|
|
500
|
+
};
|
|
501
|
+
var preserveDataSelectionForValueOption = (valueOption, selector) => {
|
|
502
|
+
if (valueOption) {
|
|
503
|
+
const dataSelectors = (0, dsl_exports.getDataSelectorsFromDSL)(valueOption);
|
|
504
|
+
const lastDataSelector = dataSelectors[dataSelectors.length - 1];
|
|
505
|
+
if (lastDataSelector.includes("seriesByIndex") || lastDataSelector.includes("seriesByName")) {
|
|
506
|
+
return `${valueOption} | ${selector}`;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
};
|
|
511
|
+
var addsDataSelectorToOptions = (dataOptions, selector) => {
|
|
512
|
+
const updatedDataOptions = {};
|
|
513
|
+
Object.keys(dataOptions).forEach((key) => {
|
|
514
|
+
const statement = dataOptions[key];
|
|
515
|
+
const updatedDSL = preserveDataSelectionForValueOption(statement, selector);
|
|
516
|
+
if (updatedDSL) {
|
|
517
|
+
updatedDataOptions[key] = updatedDSL;
|
|
518
|
+
} else {
|
|
519
|
+
updatedDataOptions[key] = statement;
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
return updatedDataOptions;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// src/visualizations/choroplethSvg.ts
|
|
526
|
+
var optionRenames2 = {
|
|
527
|
+
featureId: "areaIds",
|
|
528
|
+
value: "areaValues",
|
|
529
|
+
fill: "areaColors"
|
|
530
|
+
};
|
|
531
|
+
var defaultOptionChanges = {
|
|
532
|
+
areaIds: "> primary | seriesByIndex(0)",
|
|
533
|
+
areaValues: "> primary | seriesByIndex(1)",
|
|
534
|
+
areaColors: "> primary | seriesByIndex(1) | gradient(fillGradientContext)"
|
|
535
|
+
};
|
|
536
|
+
var defaultContextChanges = {
|
|
537
|
+
fillGradientContext: {
|
|
538
|
+
colors: ["#7EEFDA", "#6484F6", "#C093F9", "#293873"]
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
var migrateVizToSplunkChoroplethSvg = (vizDefinition) => {
|
|
542
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
543
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
544
|
+
encoding
|
|
545
|
+
);
|
|
546
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
547
|
+
type: "splunk.choropleth.svg",
|
|
548
|
+
options: {},
|
|
549
|
+
context: {}
|
|
550
|
+
});
|
|
551
|
+
const migratedOptions = __spreadValues({}, options);
|
|
552
|
+
Object.keys(dataOptions).forEach((key) => {
|
|
553
|
+
var _a2;
|
|
554
|
+
const updatedKey = (_a2 = optionRenames2[key]) != null ? _a2 : key;
|
|
555
|
+
migratedOptions[updatedKey] = dataOptions[key];
|
|
556
|
+
});
|
|
557
|
+
migratedDefinition.options = __spreadValues(__spreadValues({}, defaultOptionChanges), migratedOptions);
|
|
558
|
+
migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges;
|
|
559
|
+
removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.choroplethSvgOptionsSchema);
|
|
560
|
+
return migratedDefinition;
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// src/visualizations/column.ts
|
|
564
|
+
var defaultChanges4 = {
|
|
565
|
+
yAxisAbbreviation: "off",
|
|
566
|
+
y2AxisAbbreviation: "off",
|
|
567
|
+
showRoundedY2AxisLabels: false,
|
|
568
|
+
legendTruncation: "ellipsisMiddle",
|
|
569
|
+
showY2MajorGridLines: true
|
|
570
|
+
};
|
|
571
|
+
var migrateVizToSplunkColumn = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
572
|
+
defaultChanges: defaultChanges4,
|
|
573
|
+
validOptions: visualization_schemas_exports.columnOptionsSchema,
|
|
574
|
+
vizDefinition,
|
|
575
|
+
vizType: "splunk.column"
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
// src/visualizations/ellipse.ts
|
|
579
|
+
var optionsToRename = {
|
|
580
|
+
fill: "fillColor",
|
|
581
|
+
stroke: "strokeColor",
|
|
582
|
+
strokeDasharray: "strokeDashStyle"
|
|
583
|
+
};
|
|
584
|
+
var migrateVizToSplunkEllipse = (vizDefinition) => {
|
|
585
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
586
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
587
|
+
type: "splunk.ellipse",
|
|
588
|
+
options,
|
|
589
|
+
context: {}
|
|
590
|
+
});
|
|
591
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
592
|
+
encoding
|
|
593
|
+
);
|
|
594
|
+
const updatedDataOptions = addsDataSelectorToOptions(dataOptions, "lastPoint()");
|
|
595
|
+
migratedDefinition.options = __spreadValues(__spreadValues({}, options), updatedDataOptions);
|
|
596
|
+
migratedDefinition.options = renameVizOptions(migratedDefinition.options, optionsToRename);
|
|
597
|
+
removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.ellipseOptionsSchema);
|
|
598
|
+
migratedDefinition.context = dataContext;
|
|
599
|
+
return migratedDefinition;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// src/utils/gauges.ts
|
|
603
|
+
var consolidateDisplayOption = (showOption, percentageOption) => {
|
|
604
|
+
if (showOption === false) {
|
|
605
|
+
return "off";
|
|
606
|
+
}
|
|
607
|
+
if (percentageOption === true) {
|
|
608
|
+
return "percentage";
|
|
609
|
+
}
|
|
610
|
+
if (showOption === true) {
|
|
611
|
+
return "number";
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// src/visualizations/fillergauge.ts
|
|
617
|
+
var optionRenames3 = {
|
|
618
|
+
majorUnit: "majorTickInterval"
|
|
619
|
+
};
|
|
620
|
+
var previousRangeValueConfig = [
|
|
621
|
+
{ to: 10, value: "#5fbcff" },
|
|
622
|
+
{ from: 10, to: 30, value: "#4beba8" },
|
|
623
|
+
{ from: 30, to: 50, value: "#f4df7a" },
|
|
624
|
+
{ from: 50, to: 70, value: "#fc9850" },
|
|
625
|
+
{ from: 70, to: 100, value: "#ff7152" }
|
|
626
|
+
];
|
|
627
|
+
var defaultChanges5 = {
|
|
628
|
+
gaugeColor: "> value | rangeValue(gaugeColorRangeValueContext)",
|
|
629
|
+
value: "> primary | seriesByIndex(0) | lastPoint()"
|
|
630
|
+
};
|
|
631
|
+
var migrateVizToSplunkFillerGauge = (vizDefinition) => {
|
|
632
|
+
var _b;
|
|
633
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
634
|
+
const migratedVisualization = __spreadProps(__spreadValues({
|
|
635
|
+
options
|
|
636
|
+
}, otherDefinitionParts), {
|
|
637
|
+
type: "splunk.fillergauge",
|
|
638
|
+
context: {}
|
|
639
|
+
});
|
|
640
|
+
const renamedOptions = renameVizOptions(options, optionRenames3);
|
|
641
|
+
const { options: encodingOptions, context: gaugeColorContext } = encodingToDynamicOptionsDSL(
|
|
642
|
+
encoding
|
|
643
|
+
);
|
|
644
|
+
const originalGaugeValue = encodingOptions.value;
|
|
645
|
+
if (typeof originalGaugeValue === "string") {
|
|
646
|
+
encodingOptions.value = (_b = preserveDataSelectionForValueOption(originalGaugeValue, "lastPoint()")) != null ? _b : originalGaugeValue;
|
|
647
|
+
}
|
|
648
|
+
if (encodingOptions == null ? void 0 : encodingOptions.gaugeColor) {
|
|
649
|
+
migratedVisualization.context = gaugeColorContext;
|
|
650
|
+
} else {
|
|
651
|
+
migratedVisualization.context = {
|
|
652
|
+
gaugeColorRangeValueContext: previousRangeValueConfig
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
const { showLabels, usePercentageRange, showValue, usePercentageValue } = options;
|
|
656
|
+
const labelDisplay = consolidateDisplayOption(showLabels, usePercentageRange);
|
|
657
|
+
const valueDisplay = consolidateDisplayOption(showValue, usePercentageValue);
|
|
658
|
+
migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultChanges5), renamedOptions), encodingOptions), typeof labelDisplay === "string" && { labelDisplay }), typeof valueDisplay === "string" && { valueDisplay });
|
|
659
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.fillerGaugeOptionsSchema);
|
|
660
|
+
return migratedVisualization;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// src/visualizations/line.ts
|
|
664
|
+
var defaultChanges6 = {
|
|
665
|
+
yAxisAbbreviation: "off",
|
|
666
|
+
y2AxisAbbreviation: "off",
|
|
667
|
+
showRoundedY2AxisLabels: false,
|
|
668
|
+
legendTruncation: "ellipsisMiddle",
|
|
669
|
+
showY2MajorGridLines: true
|
|
670
|
+
};
|
|
671
|
+
var migrateVizToSplunkLine = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
672
|
+
defaultChanges: defaultChanges6,
|
|
673
|
+
validOptions: visualization_schemas_exports.lineOptionsSchema,
|
|
674
|
+
vizDefinition,
|
|
675
|
+
vizType: "splunk.line"
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
// src/visualizations/image.ts
|
|
679
|
+
var migrateVizToSplunkImage = (vizDefinition) => {
|
|
680
|
+
const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
|
|
681
|
+
const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.image", context: {} });
|
|
682
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.imageOptionsSchema);
|
|
683
|
+
return migratedVisualization;
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
// src/visualizations/markdown.ts
|
|
687
|
+
var migrateVizToSplunkMarkdown = (vizDefinition) => {
|
|
688
|
+
const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
|
|
689
|
+
const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.markdown", context: {} });
|
|
690
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.markdownOptionsSchema);
|
|
691
|
+
return migratedVisualization;
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// src/visualizations/markergauge.ts
|
|
695
|
+
var defaultChanges7 = {
|
|
696
|
+
gaugeRanges: [
|
|
697
|
+
{ from: 90, to: 100, value: "#CB3B43" },
|
|
698
|
+
{ from: 50, to: 90, value: "#F4DF7A" },
|
|
699
|
+
{ from: 0, to: 50, value: "#4BEBA8" }
|
|
700
|
+
],
|
|
701
|
+
value: "> primary | seriesByIndex(0) | lastPoint()"
|
|
702
|
+
};
|
|
703
|
+
var optionRenames4 = {
|
|
704
|
+
majorUnit: "majorTickInterval",
|
|
705
|
+
ranges: "gaugeRanges"
|
|
706
|
+
};
|
|
707
|
+
var migrateVizToSplunkMarkerGauge = (vizDefinition) => {
|
|
708
|
+
var _b;
|
|
709
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
710
|
+
const migratedVisualization = __spreadProps(__spreadValues({
|
|
711
|
+
options
|
|
712
|
+
}, otherDefinitionParts), {
|
|
713
|
+
type: "splunk.markergauge",
|
|
714
|
+
context: {}
|
|
715
|
+
});
|
|
716
|
+
const renamedOptions = renameVizOptions(options, optionRenames4);
|
|
717
|
+
const { options: dataOptions } = encodingToDynamicOptionsDSL(encoding);
|
|
718
|
+
const originalGaugeValue = dataOptions.value;
|
|
719
|
+
if (typeof originalGaugeValue === "string") {
|
|
720
|
+
dataOptions.value = (_b = preserveDataSelectionForValueOption(originalGaugeValue, "firstPoint()")) != null ? _b : originalGaugeValue;
|
|
721
|
+
}
|
|
722
|
+
const { showLabels, usePercentageRange, showValue, usePercentageValue } = renamedOptions;
|
|
723
|
+
const labelDisplay = consolidateDisplayOption(showLabels, usePercentageRange);
|
|
724
|
+
const valueDisplay = consolidateDisplayOption(showValue, usePercentageValue);
|
|
725
|
+
migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultChanges7), renamedOptions), dataOptions), typeof labelDisplay === "string" && { labelDisplay }), typeof valueDisplay === "string" && { valueDisplay });
|
|
726
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.markerGaugeOptionsSchema);
|
|
727
|
+
return migratedVisualization;
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// src/visualizations/pie.ts
|
|
731
|
+
var migratePieChartLabelAndPercent = (options) => {
|
|
732
|
+
if (!("chart.showLabels" in options) && !("chart.showPercent" in options)) {
|
|
733
|
+
return {};
|
|
734
|
+
}
|
|
735
|
+
if (!("chart.showLabels" in options) && "chart.showPercent" in options) {
|
|
736
|
+
return { labelDisplay: options["chart.showPercent"] ? "valuesAndPercentage" : "values" };
|
|
737
|
+
}
|
|
738
|
+
if ("chart.showLabels" in options && !("chart.showPercent" in options)) {
|
|
739
|
+
return { labelDisplay: options["chart.showLabels"] ? "values" : "off" };
|
|
740
|
+
}
|
|
741
|
+
const labelOption = {
|
|
742
|
+
labelDisplay: "values"
|
|
743
|
+
};
|
|
744
|
+
if (options["chart.showLabels"] && options["chart.showPercent"]) {
|
|
745
|
+
labelOption.labelDisplay = "valuesAndPercentage";
|
|
746
|
+
}
|
|
747
|
+
if (!options["chart.showLabels"]) {
|
|
748
|
+
labelOption.labelDisplay = "off";
|
|
749
|
+
}
|
|
750
|
+
return labelOption;
|
|
751
|
+
};
|
|
752
|
+
var migrateDonutChart = (options) => {
|
|
753
|
+
if (options.hasDonutHole) {
|
|
754
|
+
if (options["legend.placement"] === "none") {
|
|
755
|
+
return { labelDisplay: "off" };
|
|
756
|
+
}
|
|
757
|
+
return { labelDisplay: "values" };
|
|
758
|
+
}
|
|
759
|
+
return {};
|
|
760
|
+
};
|
|
761
|
+
var migrateFieldColors = (options) => {
|
|
762
|
+
if ("fieldColors" in options) {
|
|
763
|
+
return {
|
|
764
|
+
seriesColorsByField: otherValueReplacements.seriesColorsByField(options.fieldColors)
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
return {};
|
|
768
|
+
};
|
|
769
|
+
var migrateVizToSplunkPie = (vizDefinition) => {
|
|
770
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
771
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
772
|
+
type: "splunk.pie",
|
|
773
|
+
options: {},
|
|
774
|
+
context: {}
|
|
775
|
+
});
|
|
776
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
777
|
+
encoding
|
|
778
|
+
);
|
|
779
|
+
const migratedOptions = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, migratePieChartLabelAndPercent(options)), migrateChartingOptions(options)), migrateFieldColors(options)), migrateDonutChart(options)), dataOptions);
|
|
780
|
+
Object.keys(migratedOptions).forEach((key) => {
|
|
781
|
+
if (!visualization_schemas_exports.pieOptionsSchema[key]) {
|
|
782
|
+
delete migratedOptions[key];
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
migratedDefinition.options = migratedOptions;
|
|
786
|
+
migratedDefinition.context = dataContext;
|
|
787
|
+
return migratedDefinition;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
// src/visualizations/scatter.ts
|
|
791
|
+
var defaultChanges8 = {
|
|
792
|
+
yAxisAbbreviation: "off",
|
|
793
|
+
legendTruncation: "ellipsisMiddle"
|
|
794
|
+
};
|
|
795
|
+
var migrateVizToSplunkScatter = (vizDefinition) => migrateBaseChartingVizDefinition({
|
|
796
|
+
defaultChanges: defaultChanges8,
|
|
797
|
+
validOptions: visualization_schemas_exports.scatterOptionsSchema,
|
|
798
|
+
vizDefinition,
|
|
799
|
+
vizType: "splunk.scatter"
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
// src/visualizations/rectangle.ts
|
|
803
|
+
var optionsToRename2 = {
|
|
804
|
+
fill: "fillColor",
|
|
805
|
+
stroke: "strokeColor",
|
|
806
|
+
strokeDasharray: "strokeDashStyle",
|
|
807
|
+
strokeLinejoin: "strokeJoinStyle"
|
|
808
|
+
};
|
|
809
|
+
var migrateVizToSplunkRectangle = (vizDefinition) => {
|
|
810
|
+
const _a = vizDefinition, { encoding = {}, options } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
811
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
812
|
+
type: "splunk.rectangle",
|
|
813
|
+
options: {},
|
|
814
|
+
context: {}
|
|
815
|
+
});
|
|
816
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
817
|
+
encoding
|
|
818
|
+
);
|
|
819
|
+
const updatedDataOptions = addsDataSelectorToOptions(dataOptions, "lastPoint()");
|
|
820
|
+
migratedDefinition.options = __spreadValues(__spreadValues({}, options), updatedDataOptions);
|
|
821
|
+
migratedDefinition.options = renameVizOptions(migratedDefinition.options, optionsToRename2);
|
|
822
|
+
removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.rectangleOptionsSchema);
|
|
823
|
+
migratedDefinition.context = dataContext;
|
|
824
|
+
return migratedDefinition;
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// src/utils/singlevalue.ts
|
|
828
|
+
var consolidateTrendDisplay = (trendDisplayMode, showTrendIndicator) => {
|
|
829
|
+
if (showTrendIndicator === false) {
|
|
830
|
+
return "off";
|
|
831
|
+
}
|
|
832
|
+
if (["absolute", "percent"].includes(trendDisplayMode)) {
|
|
833
|
+
return trendDisplayMode;
|
|
834
|
+
}
|
|
835
|
+
if (showTrendIndicator === true) {
|
|
836
|
+
return "absolute";
|
|
837
|
+
}
|
|
838
|
+
return null;
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// src/visualizations/singlevalue.ts
|
|
842
|
+
var defaultsToRetain = {
|
|
843
|
+
showSparklineAreaGraph: false,
|
|
844
|
+
sparklineValues: '> primary | seriesByTypes("number", "string")'
|
|
845
|
+
};
|
|
846
|
+
var optionRenames5 = {
|
|
847
|
+
useTrendUnits: "shouldAbbreviateTrendValue",
|
|
848
|
+
useThousandSeparators: "shouldUseThousandSeparators",
|
|
849
|
+
sparklineAreaGraph: "showSparklineAreaGraph",
|
|
850
|
+
sparklineFillColor: "sparklineAreaColor",
|
|
851
|
+
sparklineAcceptNullData: "shouldSparklineAcceptNullData",
|
|
852
|
+
deltaFontSize: "trendFontSize"
|
|
853
|
+
};
|
|
854
|
+
var consolidateSparklineDisplay = (sparklinePosition, showSparkline) => {
|
|
855
|
+
if (showSparkline === false) {
|
|
856
|
+
return "off";
|
|
857
|
+
}
|
|
858
|
+
if (["before", "after", "below"].includes(sparklinePosition)) {
|
|
859
|
+
return sparklinePosition;
|
|
860
|
+
}
|
|
861
|
+
if (showSparkline === true) {
|
|
862
|
+
return "below";
|
|
863
|
+
}
|
|
864
|
+
return null;
|
|
865
|
+
};
|
|
866
|
+
var migrateVizToSplunkSingleValue = (vizDefinition) => {
|
|
867
|
+
var _b, _c, _d;
|
|
868
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
869
|
+
const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
870
|
+
type: "splunk.singlevalue",
|
|
871
|
+
context: {},
|
|
872
|
+
options: {}
|
|
873
|
+
});
|
|
874
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
875
|
+
encoding
|
|
876
|
+
);
|
|
877
|
+
const migratedDataOptions = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (dataOptions == null ? void 0 : dataOptions.trend) && { sparklineValues: dataOptions.trend }), (dataOptions == null ? void 0 : dataOptions.majorColor) && {
|
|
878
|
+
majorColor: (_b = preserveDataSelectionForValueOption(dataOptions.majorColor, "lastPoint()")) != null ? _b : dataOptions.majorColor
|
|
879
|
+
}), (dataOptions == null ? void 0 : dataOptions.deltaColor) && {
|
|
880
|
+
trendColor: (_c = preserveDataSelectionForValueOption(dataOptions.deltaColor, "lastPoint()")) != null ? _c : dataOptions.deltaColor
|
|
881
|
+
}), (dataOptions == null ? void 0 : dataOptions.fill) && {
|
|
882
|
+
backgroundColor: (_d = preserveDataSelectionForValueOption(dataOptions.fill, "lastPoint()")) != null ? _d : dataOptions.fill
|
|
883
|
+
});
|
|
884
|
+
const renamedOptions = renameVizOptions(options, optionRenames5);
|
|
885
|
+
const { trendDisplayMode, showTrendIndicator, showSparkline, sparklinePosition } = renamedOptions;
|
|
886
|
+
const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
|
|
887
|
+
const sparklineDisplay = consolidateSparklineDisplay(
|
|
888
|
+
sparklinePosition,
|
|
889
|
+
showSparkline
|
|
890
|
+
);
|
|
891
|
+
migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay }), typeof sparklineDisplay === "string" && { sparklineDisplay });
|
|
892
|
+
migratedVisualization.context = dataContext;
|
|
893
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueOptionsSchema);
|
|
894
|
+
return migratedVisualization;
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// src/visualizations/singlevalueicon.ts
|
|
898
|
+
var defaultsToRetain2 = {
|
|
899
|
+
majorValue: "> primary | seriesByIndex(0) | lastPoint()",
|
|
900
|
+
trendValue: "> primary | seriesByIndex(0) | delta(-2)"
|
|
901
|
+
};
|
|
902
|
+
var optionsToRename3 = {
|
|
903
|
+
useTrendUnits: "shouldAbbreviateTrendValue",
|
|
904
|
+
useThousandSeparators: "shouldUseThousandSeparators",
|
|
905
|
+
deltaColor: "trendColor",
|
|
906
|
+
color: "iconColor"
|
|
907
|
+
};
|
|
908
|
+
var migrateVizToSplunkSingleValueIcon = (vizDefinition) => {
|
|
909
|
+
var _b, _c, _d;
|
|
910
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
911
|
+
const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
912
|
+
type: "splunk.singlevalueicon",
|
|
913
|
+
context: {},
|
|
914
|
+
options: {}
|
|
915
|
+
});
|
|
916
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
917
|
+
encoding
|
|
918
|
+
);
|
|
919
|
+
const migratedDataOptions = __spreadValues(__spreadValues({}, (dataOptions == null ? void 0 : dataOptions.trend) && {
|
|
920
|
+
majorValue: (_b = preserveDataSelectionForValueOption(dataOptions.trend, "lastPoint()")) != null ? _b : dataOptions.trend,
|
|
921
|
+
trendValue: (_c = preserveDataSelectionForValueOption(dataOptions.trend, "delta(-2)")) != null ? _c : dataOptions.trend
|
|
922
|
+
}), (dataOptions == null ? void 0 : dataOptions.fill) && {
|
|
923
|
+
backgroundColor: (_d = preserveDataSelectionForValueOption(dataOptions.fill, "lastPoint()")) != null ? _d : dataOptions.fill
|
|
924
|
+
});
|
|
925
|
+
const renamedOptions = renameVizOptions(options, optionsToRename3);
|
|
926
|
+
const { trendDisplayMode, showTrendIndicator } = renamedOptions;
|
|
927
|
+
const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
|
|
928
|
+
migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain2), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay });
|
|
929
|
+
migratedVisualization.context = dataContext;
|
|
930
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueIconOptionsSchema);
|
|
931
|
+
return migratedVisualization;
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
// src/visualizations/singlevalueradial.ts
|
|
935
|
+
var defaultsToRetain3 = {
|
|
936
|
+
majorValue: "> primary | seriesByIndex(0) | lastPoint()",
|
|
937
|
+
trendValue: "> primary | seriesByIndex(0) | delta(-2)"
|
|
938
|
+
};
|
|
939
|
+
var optionRenames6 = {
|
|
940
|
+
useTrendUnits: "shouldAbbreviateTrendValue",
|
|
941
|
+
useThousandSeparators: "shouldUseThousandSeparators"
|
|
942
|
+
};
|
|
943
|
+
var migrateVizToSplunkSingleValueRadial = (vizDefinition) => {
|
|
944
|
+
var _b, _c, _d;
|
|
945
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
946
|
+
const migratedVisualization = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
947
|
+
type: "splunk.singlevalueradial",
|
|
948
|
+
context: {},
|
|
949
|
+
options: {}
|
|
950
|
+
});
|
|
951
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
952
|
+
encoding
|
|
953
|
+
);
|
|
954
|
+
const { trend: originalTrend, fill: originalFill } = dataOptions;
|
|
955
|
+
const migratedDataOptions = __spreadValues(__spreadValues({}, originalTrend && {
|
|
956
|
+
majorValue: (_b = preserveDataSelectionForValueOption(originalTrend, "lastPoint()")) != null ? _b : originalTrend,
|
|
957
|
+
trendValue: (_c = preserveDataSelectionForValueOption(originalTrend, "delta(-2)")) != null ? _c : originalTrend
|
|
958
|
+
}), originalFill && {
|
|
959
|
+
backgroundColor: (_d = preserveDataSelectionForValueOption(originalFill, "lastPoint()")) != null ? _d : originalFill
|
|
960
|
+
});
|
|
961
|
+
const renamedOptions = renameVizOptions(options, optionRenames6);
|
|
962
|
+
const { trendDisplayMode, showTrendIndicator } = renamedOptions;
|
|
963
|
+
const trendDisplay = consolidateTrendDisplay(trendDisplayMode, showTrendIndicator);
|
|
964
|
+
migratedVisualization.options = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultsToRetain3), renamedOptions), migratedDataOptions), typeof trendDisplay === "string" && { trendDisplay });
|
|
965
|
+
migratedVisualization.context = dataContext;
|
|
966
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.singleValueRadialOptionsSchema);
|
|
967
|
+
return migratedVisualization;
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
// esm-externals:lodash
|
|
971
|
+
var lodash_exports = {};
|
|
972
|
+
__export(lodash_exports, {
|
|
973
|
+
default: () => lodash_default
|
|
974
|
+
});
|
|
975
|
+
var defaultImport4 = __toESM(require("lodash"));
|
|
976
|
+
__reExport(lodash_exports, require("lodash"));
|
|
977
|
+
var lodash_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
|
|
978
|
+
|
|
979
|
+
// esm-externals:@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides
|
|
980
|
+
var deepMergeWithArrayPrimitiveOverrides_exports = {};
|
|
981
|
+
__export(deepMergeWithArrayPrimitiveOverrides_exports, {
|
|
982
|
+
default: () => deepMergeWithArrayPrimitiveOverrides_default
|
|
983
|
+
});
|
|
984
|
+
var defaultImport5 = __toESM(require("@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides"));
|
|
985
|
+
__reExport(deepMergeWithArrayPrimitiveOverrides_exports, require("@splunk/visualization-encoding/utils/deepMergeWithArrayPrimitiveOverrides"));
|
|
986
|
+
var deepMergeWithArrayPrimitiveOverrides_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
|
|
987
|
+
|
|
988
|
+
// src/visualizations/table.ts
|
|
989
|
+
var defaultChanges9 = {
|
|
990
|
+
count: 20
|
|
991
|
+
};
|
|
992
|
+
var optionRenames7 = {
|
|
993
|
+
rowNumbers: "showRowNumbers"
|
|
994
|
+
};
|
|
995
|
+
var migrateHeaderVisibility = (oldHeaderVisibility) => {
|
|
996
|
+
if (oldHeaderVisibility === void 0) {
|
|
997
|
+
return void 0;
|
|
998
|
+
}
|
|
999
|
+
return oldHeaderVisibility ? "inline" : "none";
|
|
1000
|
+
};
|
|
1001
|
+
var migrateAlternatingColors = (colors, optionToConvert, contextConfigName) => {
|
|
1002
|
+
const themedAlternatingColors = {
|
|
1003
|
+
rowBackgroundColors: {
|
|
1004
|
+
even: "> themes.rowBackgroundColorEven",
|
|
1005
|
+
odd: "> themes.rowBackgroundColorOdd"
|
|
1006
|
+
},
|
|
1007
|
+
rowColors: {
|
|
1008
|
+
even: "> themes.inverseTextColor",
|
|
1009
|
+
odd: "> themes.textColor"
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
const colorsContext = [];
|
|
1013
|
+
const { oddColor, evenColor } = colors;
|
|
1014
|
+
if (oddColor && evenColor) {
|
|
1015
|
+
colorsContext.push(...[oddColor, evenColor]);
|
|
1016
|
+
} else if (oddColor) {
|
|
1017
|
+
colorsContext.push(...[oddColor, themedAlternatingColors[optionToConvert].even]);
|
|
1018
|
+
} else if (evenColor) {
|
|
1019
|
+
colorsContext.push(...[themedAlternatingColors[optionToConvert].odd, evenColor]);
|
|
1020
|
+
}
|
|
1021
|
+
if (colorsContext.length) {
|
|
1022
|
+
return {
|
|
1023
|
+
contextConfigName,
|
|
1024
|
+
context: colorsContext,
|
|
1025
|
+
dsl: `> table | pick(${contextConfigName})`
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
return {};
|
|
1029
|
+
};
|
|
1030
|
+
var migrateToColumnFormat = (fieldsOption) => {
|
|
1031
|
+
const columnFormat = {};
|
|
1032
|
+
const columnFormatContext = {};
|
|
1033
|
+
if (!fieldsOption) {
|
|
1034
|
+
return {
|
|
1035
|
+
columnFormat,
|
|
1036
|
+
columnFormatContext
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
Object.entries(fieldsOption).forEach(([column, formatting]) => {
|
|
1040
|
+
const contextEntry = `formatted${column}Config`;
|
|
1041
|
+
columnFormatContext[contextEntry] = {};
|
|
1042
|
+
columnFormat[column] = {
|
|
1043
|
+
data: `> table | seriesByName("${column}") | formatByType(${contextEntry})`
|
|
1044
|
+
};
|
|
1045
|
+
const { unit, unitPosition, numberPrecision, useThousandSeparators } = formatting;
|
|
1046
|
+
if (typeof unitPosition === "string") {
|
|
1047
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "unitPosition"], unitPosition);
|
|
1048
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "string", "unitPosition"], unitPosition);
|
|
1049
|
+
}
|
|
1050
|
+
if (typeof unit === "string" || typeof unit === "number") {
|
|
1051
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "unit"], unit);
|
|
1052
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "string", "unit"], unit);
|
|
1053
|
+
}
|
|
1054
|
+
if (numberPrecision != null) {
|
|
1055
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "precision"], numberPrecision);
|
|
1056
|
+
}
|
|
1057
|
+
if (useThousandSeparators != null) {
|
|
1058
|
+
(0, lodash_exports.set)(columnFormatContext, [contextEntry, "number", "thousandSeparated"], useThousandSeparators);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
return {
|
|
1062
|
+
columnFormat,
|
|
1063
|
+
columnFormatContext
|
|
1064
|
+
};
|
|
1065
|
+
};
|
|
1066
|
+
var migrateToTableFormat = (oldOptions = {}) => {
|
|
1067
|
+
const tableFormat = {};
|
|
1068
|
+
const tableFormatContext = {
|
|
1069
|
+
formattedConfig: {}
|
|
1070
|
+
};
|
|
1071
|
+
const {
|
|
1072
|
+
unit,
|
|
1073
|
+
unitPosition: oldUnitPosition,
|
|
1074
|
+
numberPrecision: oldNumberPrecision,
|
|
1075
|
+
useThousandSeparators: oldUseThousandSeparators
|
|
1076
|
+
} = oldOptions;
|
|
1077
|
+
const unitPosition = typeof oldUnitPosition === "string" ? oldUnitPosition : "after";
|
|
1078
|
+
const numberPrecision = typeof oldNumberPrecision === "number" ? oldNumberPrecision : 0;
|
|
1079
|
+
const useThousandSeparators = typeof oldUseThousandSeparators === "boolean" ? oldUseThousandSeparators : false;
|
|
1080
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "precision"], numberPrecision);
|
|
1081
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "thousandSeparated"], useThousandSeparators);
|
|
1082
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "unitPosition"], unitPosition);
|
|
1083
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "string", "unitPosition"], unitPosition);
|
|
1084
|
+
if (typeof unit === "string" || typeof unit === "number") {
|
|
1085
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "number", "unit"], unit);
|
|
1086
|
+
(0, lodash_exports.set)(tableFormatContext, ["formattedConfig", "string", "unit"], unit);
|
|
1087
|
+
}
|
|
1088
|
+
tableFormat.data = `> table | formatByType(formattedConfig)`;
|
|
1089
|
+
const {
|
|
1090
|
+
rowBackgroundColorEven,
|
|
1091
|
+
rowBackgroundColorOdd,
|
|
1092
|
+
rowTextColorOdd,
|
|
1093
|
+
rowTextColorEven,
|
|
1094
|
+
headerTextColor,
|
|
1095
|
+
headerBackgroundColor
|
|
1096
|
+
} = oldOptions;
|
|
1097
|
+
const { context: rowColorsContext, dsl: rowColorsDSL } = migrateAlternatingColors(
|
|
1098
|
+
{ oddColor: rowTextColorOdd, evenColor: rowTextColorEven },
|
|
1099
|
+
"rowColors",
|
|
1100
|
+
"rowColorsConfig"
|
|
1101
|
+
);
|
|
1102
|
+
if (rowColorsContext && rowColorsDSL) {
|
|
1103
|
+
tableFormatContext.rowColorsConfig = rowColorsContext;
|
|
1104
|
+
tableFormat.rowColors = rowColorsDSL;
|
|
1105
|
+
}
|
|
1106
|
+
const { context: rowBackgroundColorsContext, dsl: rowBackgroundColorsDSL } = migrateAlternatingColors(
|
|
1107
|
+
{ oddColor: rowBackgroundColorOdd, evenColor: rowBackgroundColorEven },
|
|
1108
|
+
"rowBackgroundColors",
|
|
1109
|
+
"rowBackgroundColorsConfig"
|
|
1110
|
+
);
|
|
1111
|
+
if (rowBackgroundColorsContext && rowBackgroundColorsDSL) {
|
|
1112
|
+
tableFormat.rowBackgroundColors = rowBackgroundColorsDSL;
|
|
1113
|
+
tableFormatContext.rowBackgroundColorsConfig = rowBackgroundColorsContext;
|
|
1114
|
+
}
|
|
1115
|
+
if (headerTextColor) {
|
|
1116
|
+
tableFormat.headerColor = headerTextColor;
|
|
1117
|
+
}
|
|
1118
|
+
if (headerBackgroundColor) {
|
|
1119
|
+
tableFormat.headerBackgroundColor = headerBackgroundColor;
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
tableFormat,
|
|
1123
|
+
tableFormatContext
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
var migrateVizToSplunkTable = (vizDefinition) => {
|
|
1127
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
1128
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
1129
|
+
type: "splunk.table",
|
|
1130
|
+
options: {},
|
|
1131
|
+
context: {}
|
|
1132
|
+
});
|
|
1133
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
1134
|
+
encoding
|
|
1135
|
+
);
|
|
1136
|
+
const renamedOptions = renameVizOptions(options, optionRenames7);
|
|
1137
|
+
const headerVisibility = migrateHeaderVisibility(renamedOptions.showHeader);
|
|
1138
|
+
const { tableFormat, tableFormatContext } = migrateToTableFormat(renamedOptions);
|
|
1139
|
+
const { columnFormat, columnFormatContext } = migrateToColumnFormat(
|
|
1140
|
+
renamedOptions.fields
|
|
1141
|
+
);
|
|
1142
|
+
const migratedDataOptions = __spreadValues({}, (dataOptions == null ? void 0 : dataOptions.columns) && { table: dataOptions.columns });
|
|
1143
|
+
const formattingOptions = __spreadProps(__spreadValues(__spreadValues({}, !(0, lodash_exports.isEmpty)(columnFormat) && { columnFormat }), typeof headerVisibility === "string" && { headerVisibility }), {
|
|
1144
|
+
tableFormat
|
|
1145
|
+
});
|
|
1146
|
+
const migratedOptions = (0, deepMergeWithArrayPrimitiveOverrides_exports.deepMergeWithArrayPrimitiveOverrides)(
|
|
1147
|
+
{},
|
|
1148
|
+
defaultChanges9,
|
|
1149
|
+
formattingOptions,
|
|
1150
|
+
migratedDataOptions,
|
|
1151
|
+
renamedOptions
|
|
1152
|
+
);
|
|
1153
|
+
Object.keys(migratedOptions).forEach((key) => {
|
|
1154
|
+
if (!visualization_schemas_exports.tableOptionsSchema[key]) {
|
|
1155
|
+
delete migratedOptions[key];
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
migratedDefinition.context = __spreadValues(__spreadValues(__spreadValues({}, dataContext), !(0, lodash_exports.isEmpty)(columnFormatContext) && __spreadValues({}, columnFormatContext)), tableFormatContext);
|
|
1159
|
+
migratedDefinition.options = migratedOptions;
|
|
1160
|
+
return migratedDefinition;
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
// src/visualizations/text.ts
|
|
1164
|
+
var optionsToRename4 = {
|
|
1165
|
+
textColor: "fontColor",
|
|
1166
|
+
content: "markdown"
|
|
1167
|
+
};
|
|
1168
|
+
var convertTextContentToMarkDown = (fontWeight, fontSize, textContent = "") => {
|
|
1169
|
+
if (!lodash_exports.isNumber(fontSize)) {
|
|
1170
|
+
return textContent;
|
|
1171
|
+
}
|
|
1172
|
+
if (textContent.trim().length === 0) {
|
|
1173
|
+
return textContent;
|
|
1174
|
+
}
|
|
1175
|
+
let markdownContent = textContent.replace(/\n*$/, "");
|
|
1176
|
+
const regex = /\n/g;
|
|
1177
|
+
if (fontWeight === "bold") {
|
|
1178
|
+
const contentStrings = markdownContent.split("\n");
|
|
1179
|
+
const stringsTrimmed = contentStrings.map(
|
|
1180
|
+
(str) => str && str.trim().length ? `**${str.trim()}**` : ""
|
|
1181
|
+
);
|
|
1182
|
+
let idx = stringsTrimmed.length - 1;
|
|
1183
|
+
while (idx >= 0 && stringsTrimmed[idx].length === 0) {
|
|
1184
|
+
stringsTrimmed.pop();
|
|
1185
|
+
idx -= 1;
|
|
1186
|
+
}
|
|
1187
|
+
return stringsTrimmed.join("\\\n");
|
|
1188
|
+
}
|
|
1189
|
+
markdownContent = markdownContent.replace(regex, "\\\n");
|
|
1190
|
+
return markdownContent;
|
|
1191
|
+
};
|
|
1192
|
+
var convertFontSize = (fontSize) => {
|
|
1193
|
+
if (!lodash_exports.isNumber(fontSize)) {
|
|
1194
|
+
return { fontSize: "default" };
|
|
1195
|
+
}
|
|
1196
|
+
return { fontSize: "custom", customFontSize: fontSize };
|
|
1197
|
+
};
|
|
1198
|
+
var migrateVizTextToSplunkMarkdown = (vizDefinition) => {
|
|
1199
|
+
const _a = vizDefinition, { options = {} } = _a, otherDefinitionParts = __objRest(_a, ["options"]);
|
|
1200
|
+
const {
|
|
1201
|
+
fontSize = 24,
|
|
1202
|
+
fontWeight = "normal",
|
|
1203
|
+
fontFamily = "Splunk Platform Sans",
|
|
1204
|
+
rotation = 0
|
|
1205
|
+
} = options;
|
|
1206
|
+
const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.markdown", context: {} });
|
|
1207
|
+
migratedVisualization.options = renameVizOptions(migratedVisualization.options, optionsToRename4);
|
|
1208
|
+
const migratedVizOptions = migratedVisualization.options;
|
|
1209
|
+
migratedVizOptions.markdown = convertTextContentToMarkDown(
|
|
1210
|
+
fontWeight,
|
|
1211
|
+
fontSize,
|
|
1212
|
+
migratedVizOptions.markdown
|
|
1213
|
+
);
|
|
1214
|
+
const { fontSize: fontSizeValue, customFontSize } = convertFontSize(fontSize);
|
|
1215
|
+
migratedVizOptions.fontSize = fontSizeValue;
|
|
1216
|
+
migratedVizOptions.customFontSize = customFontSize;
|
|
1217
|
+
migratedVizOptions.fontFamily = fontFamily;
|
|
1218
|
+
migratedVizOptions.rotation = rotation;
|
|
1219
|
+
removeInvalidOptions(migratedVizOptions, visualization_schemas_exports.markdownOptionsSchema);
|
|
1220
|
+
return migratedVisualization;
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
// src/visualizations/punchcard.ts
|
|
1224
|
+
var defaultContext = {
|
|
1225
|
+
bubbleColorConfig: {
|
|
1226
|
+
colors: ["rgba(123,86,219,0.4)", "rgba(123,86,219,1)"]
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
var optionsToRename5 = {
|
|
1230
|
+
showBubbleLabels: "bubbleLabelDisplay",
|
|
1231
|
+
bubbleScale: "bubbleSizeMethod",
|
|
1232
|
+
isBubbleSizeDynamic: "showDynamicBubbleSize",
|
|
1233
|
+
maxBubbleRadius: "bubbleRadiusMax",
|
|
1234
|
+
minBubbleRadius: "bubbleRadiusMin",
|
|
1235
|
+
maxBubbleSize: "bubbleSizeMax",
|
|
1236
|
+
minBubbleSize: "bubbleSizeMin",
|
|
1237
|
+
showLegend: "legendDisplay",
|
|
1238
|
+
useDefaultSort: "showDefaultSort"
|
|
1239
|
+
};
|
|
1240
|
+
var consolidateLegendDisplay = (vizOptions) => {
|
|
1241
|
+
if (!vizOptions) {
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const options = vizOptions;
|
|
1245
|
+
if (options.legendDisplay) {
|
|
1246
|
+
options.legendDisplay = "right";
|
|
1247
|
+
} else if (options.legendDisplay === false) {
|
|
1248
|
+
options.legendDisplay = "off";
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
var consolidateBubbleLabelDisplay = (vizOptions) => {
|
|
1252
|
+
if (!vizOptions) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
const options = vizOptions;
|
|
1256
|
+
if (options.bubbleLabelDisplay === "none") {
|
|
1257
|
+
options.bubbleLabelDisplay = "off";
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
var convertGradientConfig = (minBubbleColorIntensity, defaultBubbleColorConfig) => {
|
|
1261
|
+
if (!defaultBubbleColorConfig || !defaultBubbleColorConfig.colors || !defaultBubbleColorConfig.colors[0] || typeof minBubbleColorIntensity !== "number") {
|
|
1262
|
+
return null;
|
|
1263
|
+
}
|
|
1264
|
+
const firstColor = defaultBubbleColorConfig.colors[0];
|
|
1265
|
+
const firstColorUpdated = `${firstColor.substring(
|
|
1266
|
+
0,
|
|
1267
|
+
firstColor.lastIndexOf(",")
|
|
1268
|
+
)},${minBubbleColorIntensity})`;
|
|
1269
|
+
const colors = [...defaultBubbleColorConfig.colors];
|
|
1270
|
+
colors[0] = firstColorUpdated;
|
|
1271
|
+
const bubbleColorConfigUpdated = __spreadProps(__spreadValues({}, defaultBubbleColorConfig), { colors });
|
|
1272
|
+
return bubbleColorConfigUpdated;
|
|
1273
|
+
};
|
|
1274
|
+
var convertColorModeOption = (visualizationDefinition) => {
|
|
1275
|
+
const visualizationDef = visualizationDefinition;
|
|
1276
|
+
if (!visualizationDef || !visualizationDef.options) {
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
if (visualizationDef.options.colorMode === "sequential") {
|
|
1280
|
+
visualizationDef.options.colorMode = "dynamic";
|
|
1281
|
+
}
|
|
1282
|
+
if (!visualizationDef.options.colorMode) {
|
|
1283
|
+
visualizationDef.options.colorMode = "categorical";
|
|
1284
|
+
}
|
|
1285
|
+
const { minBubbleColorIntensity } = visualizationDef.options;
|
|
1286
|
+
if ((!visualizationDef.options.category || visualizationDef.options.colorMode !== "categorical") && minBubbleColorIntensity && typeof minBubbleColorIntensity === "number") {
|
|
1287
|
+
const bubbleColorConfig = convertGradientConfig(
|
|
1288
|
+
minBubbleColorIntensity,
|
|
1289
|
+
defaultContext.bubbleColorConfig
|
|
1290
|
+
);
|
|
1291
|
+
if (bubbleColorConfig) {
|
|
1292
|
+
visualizationDef.context = __spreadProps(__spreadValues({}, visualizationDef.context), { bubbleColorConfig });
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
var migrateVizToSplunkPunchcard = (vizDefinition) => {
|
|
1297
|
+
const _a = vizDefinition, { options = {}, encoding = {} } = _a, otherDefinitionParts = __objRest(_a, ["options", "encoding"]);
|
|
1298
|
+
const migratedVisualization = __spreadProps(__spreadValues({ options }, otherDefinitionParts), { type: "splunk.punchcard", context: {} });
|
|
1299
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
1300
|
+
encoding
|
|
1301
|
+
);
|
|
1302
|
+
const renamedOptions = renameVizOptions(migratedVisualization.options, optionsToRename5);
|
|
1303
|
+
consolidateLegendDisplay(renamedOptions);
|
|
1304
|
+
consolidateBubbleLabelDisplay(renamedOptions);
|
|
1305
|
+
migratedVisualization.options = __spreadValues(__spreadValues({}, renamedOptions), dataOptions);
|
|
1306
|
+
migratedVisualization.context = dataContext;
|
|
1307
|
+
convertColorModeOption(migratedVisualization);
|
|
1308
|
+
removeInvalidOptions(migratedVisualization.options, visualization_schemas_exports.punchcardOptionsSchema);
|
|
1309
|
+
return migratedVisualization;
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// src/visualizations/choropleth.ts
|
|
1313
|
+
var optionRenames8 = {
|
|
1314
|
+
fillColor: "choroplethEmptyAreaColor",
|
|
1315
|
+
strokeColor: "choroplethStrokeColor",
|
|
1316
|
+
featureId: "areaIds",
|
|
1317
|
+
fill: "dataColors",
|
|
1318
|
+
value: "areaValues"
|
|
1319
|
+
};
|
|
1320
|
+
var defaultContextChanges2 = {
|
|
1321
|
+
fillGradientContext: {
|
|
1322
|
+
colors: "> themes.defaultGradientMigrationConfig"
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
var defaultStrokeColor = "#689C8D";
|
|
1326
|
+
var defaultEmptyAreaColor = "#EAEFF2";
|
|
1327
|
+
var migrateVizToSplunkMapChoropleth = (vizDefinition) => {
|
|
1328
|
+
const _a = vizDefinition, { encoding = {}, options = {} } = _a, otherDefinitionParts = __objRest(_a, ["encoding", "options"]);
|
|
1329
|
+
const migratedDefinition = __spreadProps(__spreadValues({}, otherDefinitionParts), {
|
|
1330
|
+
type: "splunk.map",
|
|
1331
|
+
options: {},
|
|
1332
|
+
context: {}
|
|
1333
|
+
});
|
|
1334
|
+
const { options: dataOptions, context: dataContext } = encodingToDynamicOptionsDSL(
|
|
1335
|
+
encoding
|
|
1336
|
+
);
|
|
1337
|
+
const dynamicOptions = renameVizOptions(dataOptions, optionRenames8);
|
|
1338
|
+
const renamedOptions = renameVizOptions(options, optionRenames8);
|
|
1339
|
+
if (!("dataColors" in dynamicOptions)) {
|
|
1340
|
+
Object.assign(dynamicOptions, {
|
|
1341
|
+
dataColors: "> areaValues | gradient(fillGradientContext)"
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
let { choroplethEmptyAreaColor, choroplethStrokeColor } = renamedOptions;
|
|
1345
|
+
const { source } = renamedOptions;
|
|
1346
|
+
const layerOptions = ["choroplethEmptyAreaColor", "choroplethStrokeColor", "source"];
|
|
1347
|
+
const renamedOptionsFiltered = Object.keys(renamedOptions).filter((key) => !layerOptions.includes(key)).reduce((obj, key) => {
|
|
1348
|
+
obj[key] = renamedOptions[key];
|
|
1349
|
+
return obj;
|
|
1350
|
+
}, {});
|
|
1351
|
+
if (choroplethStrokeColor === defaultStrokeColor && choroplethEmptyAreaColor !== "transparent") {
|
|
1352
|
+
if ("backgroundColor" in renamedOptionsFiltered) {
|
|
1353
|
+
if (renamedOptionsFiltered["backgroundColor"] !== "transparent") {
|
|
1354
|
+
choroplethStrokeColor = renamedOptionsFiltered["backgroundColor"];
|
|
1355
|
+
} else {
|
|
1356
|
+
choroplethStrokeColor = "> themes.defaultBackgroundColor";
|
|
1357
|
+
}
|
|
1358
|
+
} else {
|
|
1359
|
+
choroplethStrokeColor = "> themes.defaultBackgroundColor";
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
if (choroplethEmptyAreaColor === defaultEmptyAreaColor) {
|
|
1363
|
+
choroplethEmptyAreaColor = "> themes.defaultChoroplethEmptyAreaColor";
|
|
1364
|
+
}
|
|
1365
|
+
migratedDefinition.options = __spreadProps(__spreadValues({}, renamedOptionsFiltered), {
|
|
1366
|
+
layers: [
|
|
1367
|
+
__spreadProps(__spreadValues({
|
|
1368
|
+
type: "choropleth",
|
|
1369
|
+
source
|
|
1370
|
+
}, dynamicOptions), {
|
|
1371
|
+
choroplethEmptyAreaColor,
|
|
1372
|
+
choroplethStrokeColor,
|
|
1373
|
+
choroplethOpacity: 1
|
|
1374
|
+
})
|
|
1375
|
+
],
|
|
1376
|
+
showScale: false,
|
|
1377
|
+
showBaseLayer: false,
|
|
1378
|
+
showZoomControls: false
|
|
1379
|
+
});
|
|
1380
|
+
if (vizDefinition.type === "viz.geojson.us") {
|
|
1381
|
+
migratedDefinition.options.center = [39.83, -97];
|
|
1382
|
+
migratedDefinition.options.zoom = 3;
|
|
1383
|
+
} else {
|
|
1384
|
+
migratedDefinition.options.center = [46.56, 10.35];
|
|
1385
|
+
migratedDefinition.options.zoom = 0;
|
|
1386
|
+
}
|
|
1387
|
+
migratedDefinition.context = encoding.fill ? dataContext : defaultContextChanges2;
|
|
1388
|
+
if (JSON.stringify(dataContext) === JSON.stringify({
|
|
1389
|
+
fillGradientContext: {}
|
|
1390
|
+
})) {
|
|
1391
|
+
Object.assign(migratedDefinition, {
|
|
1392
|
+
context: defaultContextChanges2
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
removeInvalidOptions(migratedDefinition.options, visualization_schemas_exports.mapOptionsSchema);
|
|
1396
|
+
return migratedDefinition;
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
// src/migrate.ts
|
|
1400
|
+
var supportedMigrations = {
|
|
1401
|
+
"viz.area": {
|
|
1402
|
+
"splunk.area": migrateVizToSplunkArea
|
|
1403
|
+
},
|
|
1404
|
+
"viz.bar": {
|
|
1405
|
+
"splunk.bar": migrateVizToSplunkBar
|
|
1406
|
+
},
|
|
1407
|
+
"viz.bubble": {
|
|
1408
|
+
"splunk.bubble": migrateVizToSplunkBubble
|
|
1409
|
+
},
|
|
1410
|
+
"viz.column": {
|
|
1411
|
+
"splunk.column": migrateVizToSplunkColumn
|
|
1412
|
+
},
|
|
1413
|
+
"viz.choropleth.svg": {
|
|
1414
|
+
"splunk.choropleth.svg": migrateVizToSplunkChoroplethSvg
|
|
1415
|
+
},
|
|
1416
|
+
"viz.geojson.us": {
|
|
1417
|
+
"splunk.map": migrateVizToSplunkMapChoropleth
|
|
1418
|
+
},
|
|
1419
|
+
"viz.geojson.world": {
|
|
1420
|
+
"splunk.map": migrateVizToSplunkMapChoropleth
|
|
1421
|
+
},
|
|
1422
|
+
"viz.ellipse": {
|
|
1423
|
+
"splunk.ellipse": migrateVizToSplunkEllipse
|
|
1424
|
+
},
|
|
1425
|
+
"viz.fillergauge": {
|
|
1426
|
+
"splunk.fillergauge": migrateVizToSplunkFillerGauge
|
|
1427
|
+
},
|
|
1428
|
+
"viz.line": {
|
|
1429
|
+
"splunk.line": migrateVizToSplunkLine
|
|
1430
|
+
},
|
|
1431
|
+
"viz.img": {
|
|
1432
|
+
"splunk.image": migrateVizToSplunkImage
|
|
1433
|
+
},
|
|
1434
|
+
"viz.markdown": {
|
|
1435
|
+
"splunk.markdown": migrateVizToSplunkMarkdown
|
|
1436
|
+
},
|
|
1437
|
+
"viz.markergauge": {
|
|
1438
|
+
"splunk.markergauge": migrateVizToSplunkMarkerGauge
|
|
1439
|
+
},
|
|
1440
|
+
"viz.pie": {
|
|
1441
|
+
"splunk.pie": migrateVizToSplunkPie
|
|
1442
|
+
},
|
|
1443
|
+
"viz.rectangle": {
|
|
1444
|
+
"splunk.rectangle": migrateVizToSplunkRectangle
|
|
1445
|
+
},
|
|
1446
|
+
"viz.singlevalue": {
|
|
1447
|
+
"splunk.singlevalue": migrateVizToSplunkSingleValue
|
|
1448
|
+
},
|
|
1449
|
+
"viz.singlevalueicon": {
|
|
1450
|
+
"splunk.singlevalueicon": migrateVizToSplunkSingleValueIcon
|
|
1451
|
+
},
|
|
1452
|
+
"viz.singlevalueradial": {
|
|
1453
|
+
"splunk.singlevalueradial": migrateVizToSplunkSingleValueRadial
|
|
1454
|
+
},
|
|
1455
|
+
"viz.scatter": {
|
|
1456
|
+
"splunk.scatter": migrateVizToSplunkScatter
|
|
1457
|
+
},
|
|
1458
|
+
"viz.table": {
|
|
1459
|
+
"splunk.table": migrateVizToSplunkTable
|
|
1460
|
+
},
|
|
1461
|
+
"viz.text": {
|
|
1462
|
+
"splunk.markdown": migrateVizTextToSplunkMarkdown
|
|
1463
|
+
},
|
|
1464
|
+
"viz.punchcard": {
|
|
1465
|
+
"splunk.punchcard": migrateVizToSplunkPunchcard
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
var inferToType = (typeFromDefinition) => {
|
|
1469
|
+
if (typeFromDefinition === "viz.img") {
|
|
1470
|
+
return "splunk.image";
|
|
1471
|
+
}
|
|
1472
|
+
if (typeFromDefinition === "viz.text") {
|
|
1473
|
+
return "splunk.markdown";
|
|
1474
|
+
}
|
|
1475
|
+
if (typeFromDefinition === "viz.geojson.us" || typeFromDefinition === "viz.geojson.world") {
|
|
1476
|
+
return "splunk.map";
|
|
1477
|
+
}
|
|
1478
|
+
return typeFromDefinition.replace(/^viz\./, "splunk.");
|
|
1479
|
+
};
|
|
1480
|
+
var migrate = ({ definition, toType: toTypeFromParams }) => {
|
|
1481
|
+
var _a;
|
|
1482
|
+
const toType = toTypeFromParams != null ? toTypeFromParams : inferToType(definition.type);
|
|
1483
|
+
if (!((_a = supportedMigrations == null ? void 0 : supportedMigrations[definition == null ? void 0 : definition.type]) == null ? void 0 : _a[toType])) {
|
|
1484
|
+
throw new Error("Migration currently not supported");
|
|
1485
|
+
}
|
|
1486
|
+
return supportedMigrations[definition.type][toType](definition);
|
|
1487
|
+
};
|
|
1488
|
+
var canMigrate = ({ fromType, toType }) => {
|
|
1489
|
+
var _a;
|
|
1490
|
+
if ((_a = supportedMigrations == null ? void 0 : supportedMigrations[fromType]) == null ? void 0 : _a[toType]) {
|
|
1491
|
+
return true;
|
|
1492
|
+
}
|
|
1493
|
+
return false;
|
|
1494
|
+
};
|
|
1495
|
+
//# sourceMappingURL=migrate.js.map
|