@splunk/visualizations 26.0.0 → 26.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Area.config.js +103 -19
- package/Area.config.js.map +1 -1
- package/Area.js +646 -243
- package/Area.js.map +1 -1
- package/Bar.config.js +105 -21
- package/Bar.config.js.map +1 -1
- package/Bar.js +653 -237
- package/Bar.js.map +1 -1
- package/Bubble.config.js +95 -21
- package/Bubble.config.js.map +1 -1
- package/Bubble.js +635 -229
- package/Bubble.js.map +1 -1
- package/ChoroplethSvg.config.js +66 -15
- package/ChoroplethSvg.config.js.map +1 -1
- package/ChoroplethSvg.js +589 -211
- package/ChoroplethSvg.js.map +1 -1
- package/Column.config.js +104 -19
- package/Column.config.js.map +1 -1
- package/Column.js +666 -239
- package/Column.js.map +1 -1
- package/Ellipse.config.js +83 -18
- package/Ellipse.config.js.map +1 -1
- package/Ellipse.js +444 -156
- package/Ellipse.js.map +1 -1
- package/Events.config.js +101 -19
- package/Events.config.js.map +1 -1
- package/Events.js +792 -322
- package/Events.js.map +1 -1
- package/FillerGauge.config.js +97 -28
- package/FillerGauge.config.js.map +1 -1
- package/FillerGauge.js +786 -390
- package/FillerGauge.js.map +1 -1
- package/Image.config.js +63 -19
- package/Image.config.js.map +1 -1
- package/Image.js +439 -164
- package/Image.js.map +1 -1
- package/Line.config.js +107 -23
- package/Line.config.js.map +1 -1
- package/Line.js +841 -456
- package/Line.js.map +1 -1
- package/LinkGraph.config.js +73 -23
- package/LinkGraph.config.js.map +1 -1
- package/LinkGraph.js +653 -230
- package/LinkGraph.js.map +1 -1
- package/MIGRATION.md +1082 -0
- package/Map.config.js +244 -99
- package/Map.config.js.map +1 -1
- package/Map.js +1223 -612
- package/Map.js.map +1 -1
- package/Markdown.config.js +71 -21
- package/Markdown.config.js.map +1 -1
- package/Markdown.js +477 -202
- package/Markdown.js.map +1 -1
- package/MarkerGauge.config.js +80 -22
- package/MarkerGauge.config.js.map +1 -1
- package/MarkerGauge.js +819 -418
- package/MarkerGauge.js.map +1 -1
- package/ParallelCoordinates.config.js +73 -19
- package/ParallelCoordinates.config.js.map +1 -1
- package/ParallelCoordinates.js +870 -491
- package/ParallelCoordinates.js.map +1 -1
- package/Pie.config.js +76 -23
- package/Pie.config.js.map +1 -1
- package/Pie.js +643 -233
- package/Pie.js.map +1 -1
- package/Punchcard.config.js +82 -30
- package/Punchcard.config.js.map +1 -1
- package/Punchcard.js +863 -387
- package/Punchcard.js.map +1 -1
- package/Rectangle.config.js +86 -20
- package/Rectangle.config.js.map +1 -1
- package/Rectangle.js +449 -159
- package/Rectangle.js.map +1 -1
- package/Sankey.config.js +85 -23
- package/Sankey.config.js.map +1 -1
- package/Sankey.js +895 -349
- package/Sankey.js.map +1 -1
- package/Scatter.config.js +97 -23
- package/Scatter.config.js.map +1 -1
- package/Scatter.js +639 -234
- package/Scatter.js.map +1 -1
- package/SingleValue.config.js +95 -25
- package/SingleValue.config.js.map +1 -1
- package/SingleValue.js +1198 -656
- package/SingleValue.js.map +1 -1
- package/SingleValueBasic.js +287 -226
- package/SingleValueBasic.js.map +1 -1
- package/SingleValueIcon.config.js +93 -23
- package/SingleValueIcon.config.js.map +1 -1
- package/SingleValueIcon.js +991 -522
- package/SingleValueIcon.js.map +1 -1
- package/SingleValueRadial.config.js +100 -27
- package/SingleValueRadial.config.js.map +1 -1
- package/SingleValueRadial.js +1185 -624
- package/SingleValueRadial.js.map +1 -1
- package/SparkLine.js +127 -68
- package/SparkLine.js.map +1 -1
- package/Table.config.js +74 -21
- package/Table.config.js.map +1 -1
- package/Table.js +827 -329
- package/Table.js.map +1 -1
- package/common/Charting.js +152 -69
- package/common/Charting.js.map +1 -1
- package/common/ChartingApi.js +25 -14
- package/common/ChartingApi.js.map +1 -1
- package/common/DocExampleWithVizSandbox.js +530 -0
- package/common/DocExampleWithVizSandbox.js.map +1 -0
- package/common/EventsDoc.js +139 -104
- package/common/EventsDoc.js.map +1 -1
- package/common/GaugeMajorTicks.js +79 -69
- package/common/GaugeMajorTicks.js.map +1 -1
- package/common/GaugeValueMarker.js +54 -45
- package/common/GaugeValueMarker.js.map +1 -1
- package/common/OptionsDoc.js +178 -87
- package/common/OptionsDoc.js.map +1 -1
- package/common/OverviewDoc.js +530 -68
- package/common/OverviewDoc.js.map +1 -1
- package/common/SplunkVisualization.js +47 -20
- package/common/SplunkVisualization.js.map +1 -1
- package/common/SplunkVisualizationApi.js +15 -9
- package/common/SplunkVisualizationApi.js.map +1 -1
- package/common/ThemesDoc.js +57 -44
- package/common/ThemesDoc.js.map +1 -1
- package/common/chartingUtils.js +52 -20
- package/common/chartingUtils.js.map +1 -1
- package/common/docUtils.js +139 -7
- package/common/docUtils.js.map +1 -1
- package/common/gaugeUtils.js +185 -102
- package/common/gaugeUtils.js.map +1 -1
- package/common/shapeUtils.js +28 -16
- package/common/shapeUtils.js.map +1 -1
- package/common/utils/configUtils.js +50 -15
- package/common/utils/configUtils.js.map +1 -1
- package/common/utils/dataUtils.js +8 -3
- package/common/utils/dataUtils.js.map +1 -1
- package/common/utils/hocUtils.js +4 -2
- package/common/utils/hocUtils.js.map +1 -1
- package/common/utils/layoutUtils.js +2 -1
- package/common/utils/layoutUtils.js.map +1 -1
- package/common/utils/mapUtils.js +288 -128
- package/common/utils/mapUtils.js.map +1 -1
- package/common/utils/singleValueUtils.js +242 -197
- package/common/utils/singleValueUtils.js.map +1 -1
- package/common/utils/testHelper.js +10 -1
- package/common/utils/testHelper.js.map +1 -1
- package/common/utils/trellisUtils.js +62 -1
- package/common/utils/trellisUtils.js.map +1 -1
- package/common/utils/urlUtils.js +3 -1
- package/common/utils/urlUtils.js.map +1 -1
- package/common/withDashboardViz.js +389 -192
- package/common/withDashboardViz.js.map +1 -1
- package/package.json +18 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@babel/runtime/helpers/toConsumableArray\"","webpack:///external \"lodash\"","webpack:///./src/common/chartingUtils.ts"],"names":["lodash_1","require","getAnnotations","_ref","annotationX","annotationColor","annotationLabel","length","map","timestamp","i","color","label","time","exports","truncateData","dataSet","truncationLimit","limit","parseInt","truncatedData","Object","assign","columns","columnData","Array","isArray","slice","mapToValues","optionValuesSCMapping","options","convertedOptions","keys","forEach","key","has","updatedValue","isUndefined","convertY2AxisOptions","_a","y2Fields","originalOptions","__rest","filter","name","join","convertOverlayFields","overlayFields","field","trim","isMultiSeriesData","data","toArrayForSeries","value","constructFieldsAndColumns","_ref2","_ref2$x","x","_ref2$y","y","xField","yFields","y2","String","concat","_toConsumableArray","series","yFieldsArray","fields","y2FieldsArray","y2AsArray","y2Field","index","indexOf","push"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,qE;;;;;;;ACAA,mC;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,IAAAA,QAAA,GAAAC,mBAAA;AAOA;;;;;;;;;AASO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA;EAAA,IAAMC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAEC,eAAe,GAAAF,IAAA,CAAfE,eAAe;IAAEC,eAAe,GAAAH,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CAAC,CAAC;;IAEtC,CAAC,CAAC;;EAEN,OAAO;IACHjD,OAAO,EAAPA,OAAO;IACP6C,MAAM,EAANA;GACH;AACL,CAAC;AA9BYtD,OAAA,CAAAwC,yBAAyB,GAAAA,yBAAA,C","file":"chartingUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 67);\n","module.exports = require(\"@babel/runtime/helpers/toConsumableArray\");","module.exports = require(\"lodash\");","import { has, isArray, isUndefined } from 'lodash';\nimport type { JsonColumnData } from './interfaces/DataSource';\n\ninterface ChartOptions {\n [key: string]: any;\n}\n\n/**\n * Get formatted annotations\n * @method getAnnotations\n * @param {Object} options\n * @param {Array} options.annotationX\n * @param {Array} options.annotationColor\n * @param {Array} options.annotationLabel\n * @returns {Array}\n */\nexport const getAnnotations = ({ annotationX, annotationColor, annotationLabel }) =>\n annotationX && annotationX.length\n ? annotationX.map((timestamp, i) => ({\n color: annotationColor && annotationColor[i],\n label: annotationLabel && annotationLabel[i],\n time: timestamp,\n }))\n : [];\n\n/**\n * Truncate the result set to given limit\n * @method truncateData\n * @param {Object} dataSet - dataSources.primary.data\n * @param {Number|String} truncationLimit - options['chart.resultTruncationLimit']\n * @returns {Object}\n */\nexport const truncateData = (dataSet, truncationLimit): Record<string, any[]> => {\n if (!dataSet) {\n return null;\n }\n\n const limit = parseInt(truncationLimit, 10);\n if (!limit || limit <= 0) {\n return dataSet;\n }\n\n const truncatedData: Record<string, Array<string[] | number[]>> = { ...dataSet };\n truncatedData.columns = truncatedData.columns.map(columnData =>\n columnData && Array.isArray(columnData) ? columnData.slice(0, limit) : columnData\n );\n return truncatedData;\n};\n\n/**\n * Helper method to update the option values into the values that SC accepts\n * @method mapToValues\n * @param {Object} options\n * @returns {Object}\n */\nexport const mapToValues = (optionValuesSCMapping: Record<string, any>) => options => {\n const convertedOptions: Record<string, any> = { ...options };\n Object.keys(optionValuesSCMapping).forEach(key => {\n if (has(options, key)) {\n const updatedValue = optionValuesSCMapping[key][options[key]];\n if (!isUndefined(updatedValue)) {\n convertedOptions[key] = updatedValue;\n }\n }\n });\n return convertedOptions;\n};\n\ninterface y2AxisOptions extends ChartOptions {\n y2Fields?: string | string[];\n}\n\n/**\n * Helper method to process options related to y2Fields\n * @method convertY2AxisOptions\n * @param {Object} originalOptions\n * @returns {Object}\n */\nexport const convertY2AxisOptions = ({\n y2Fields,\n ...originalOptions\n}: y2AxisOptions): Record<string, any> => {\n const convertedOptions: Record<string, any> = {\n ...originalOptions,\n };\n if (y2Fields) {\n convertedOptions['axisY2.enabled'] = true;\n convertedOptions['axisY2.fields'] = isArray(y2Fields)\n ? y2Fields.filter(name => name).join(',')\n : y2Fields;\n }\n return convertedOptions;\n};\n\n/**\n * Helper method to format value for overlayFields\n * @method convertOverlayFields\n * @param {Object} originalOptions\n * @returns {Object}\n */\nexport const convertOverlayFields = (originalOptions: ChartOptions): ChartOptions => {\n const convertedOptions: ChartOptions = {\n ...originalOptions,\n };\n const { overlayFields } = originalOptions;\n if (overlayFields) {\n convertedOptions.overlayFields = Array.isArray(overlayFields)\n ? overlayFields\n .filter(field => field)\n .map(field => field.trim())\n .join(',')\n : overlayFields;\n }\n return convertedOptions;\n};\n\n/**\n * checks whether data is multi series data\n * @param {array} data array\n * @return {Boolean}\n */\nexport const isMultiSeriesData = (data: string[] | string[][]): boolean =>\n Array.isArray(data) && Array.isArray(data[0]);\n/**\n * checks whether data is multi series data and returns value as array\n * @param {array} data array\n * @param {*} value to return as array\n * @return {array}\n */\nexport const toArrayForSeries = (data, value): any[] => (isMultiSeriesData(data) ? value : [value]);\n\ninterface ConstructFieldsAndColumnsParams {\n x: string[];\n y: string[] | string[][];\n xField: string;\n yFields: string | string[];\n y2?: string[] | string[][];\n y2Fields?: string | string[];\n}\nexport const constructFieldsAndColumns = ({\n x = [],\n y = [],\n xField,\n yFields,\n y2,\n y2Fields,\n}: ConstructFieldsAndColumnsParams): JsonColumnData => {\n const columns = [x.map(String), ...toArrayForSeries(y, y).map(series => series.map(String))];\n const yFieldsArray = toArrayForSeries(y, yFields);\n const fields = [{ name: xField }, ...yFieldsArray.map(field => ({ name: field }))];\n // splunk-charting requires y2 to be part of columns\n // when y & y2 options are configured with different (mutually exclusive) series\n // y2 columns need to be added to columns\n if (y2Fields) {\n const y2FieldsArray = toArrayForSeries(y2, y2Fields);\n const y2AsArray = toArrayForSeries(y2, y2).map(series => series?.map(String));\n y2FieldsArray.forEach((y2Field, index) => {\n if (yFieldsArray.indexOf(y2Field) === -1 && y2AsArray[index]) {\n fields.push({\n name: y2Field,\n });\n columns.push(y2AsArray[index]);\n }\n });\n }\n return {\n columns,\n fields,\n };\n};\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"lodash\"","webpack:///external \"@babel/runtime/helpers/toConsumableArray\"","webpack:///./src/common/chartingUtils.ts"],"names":[],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAg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WAAI,MAAM,CAAC,GAAP,CAAW,MAAX,CAAJ;AAAA,GAAjC,CAAtB,EAAb;AACA,MAAM,YAAY,GAAG,8BAAiB,CAAjB,EAAoB,OAApB,CAArB;AACA,MAAM,MAAM,IAAI;AAAE,QAAI,EAAE;AAAR,GAAJ,4BAAyB,YAAY,CAAC,GAAb,CAAiB,eAAK;AAAA,WAAK;AAAE,UAAI,EAAE;AAAR,KAAL;AAAA,GAAtB,CAAzB,EAAZ,CAHkD,CAIlD;AACA;AACA;;AACA,MAAI,QAAJ,EAAc;AACV,QAAM,aAAa,GAAG,8BAAiB,EAAjB,EAAqB,QAArB,CAAtB;AACA,QAAM,SAAS,GAAG,8BAAiB,EAAjB,EAAqB,EAArB,EAAyB,GAAzB,CAA6B,gBAAM;AAAA,aAAI,MAAM,SAAN,UAAM,WAAN,GAAM,MAAN,SAAM,CAAE,GAAR,CAAY,MAAZ,CAAJ;AAAA,KAAnC,CAAlB;AACA,iBAAa,CAAC,OAAd,CAAsB,UAAC,OAAD,EAAU,KAAV,EAAmB;AACrC,UAAI,YAAY,CAAC,OAAb,CAAqB,OAArB,MAAkC,CAAC,CAAnC,IAAwC,SAAS,CAAC,KAAD,CAArD,EAA8D;AAC1D,cAAM,CAAC,IAAP,CAAY;AACR,cAAI,EAAE;AADE,SAAZ;AAGA,eAAO,CAAC,IAAR,CAAa,SAAS,CAAC,KAAD,CAAtB;AACH;AACJ,KAPD;AAQH;;AACD,SAAO;AACH,WAAO,EAAP,OADG;AAEH,UAAM,EAAN;AAFG,GAAP;AAIH,CA9BM;;AAAM,oCAAyB,yBAAzB,C","file":"chartingUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 77);\n","module.exports = require(\"lodash\");","module.exports = require(\"@babel/runtime/helpers/toConsumableArray\");","import { has, isArray, isUndefined } from 'lodash';\nimport type { JsonColumnData } from './interfaces/DataSource';\n\ninterface ChartOptions {\n [key: string]: any;\n}\n\n/**\n * Get formatted annotations\n * @method getAnnotations\n * @param {Object} options\n * @param {Array} options.annotationX\n * @param {Array} options.annotationColor\n * @param {Array} options.annotationLabel\n * @returns {Array}\n */\nexport const getAnnotations = ({ annotationX, annotationColor, annotationLabel }) =>\n annotationX && annotationX.length\n ? annotationX.map((timestamp, i) => ({\n color: annotationColor && annotationColor[i],\n label: annotationLabel && annotationLabel[i],\n time: timestamp,\n }))\n : [];\n\n/**\n * Truncate the result set to given limit\n * @method truncateData\n * @param {Object} dataSet - dataSources.primary.data\n * @param {Number|String} truncationLimit - options['chart.resultTruncationLimit']\n * @returns {Object}\n */\nexport const truncateData = (dataSet, truncationLimit): Record<string, any[]> => {\n if (!dataSet) {\n return null;\n }\n\n const limit = parseInt(truncationLimit, 10);\n if (!limit || limit <= 0) {\n return dataSet;\n }\n\n const truncatedData: Record<string, Array<string[] | number[]>> = { ...dataSet };\n truncatedData.columns = truncatedData.columns.map(columnData =>\n columnData && Array.isArray(columnData) ? columnData.slice(0, limit) : columnData\n );\n return truncatedData;\n};\n\n/**\n * Helper method to update the option values into the values that SC accepts\n * @method mapToValues\n * @param {Object} options\n * @returns {Object}\n */\nexport const mapToValues = (optionValuesSCMapping: Record<string, any>) => options => {\n const convertedOptions: Record<string, any> = { ...options };\n Object.keys(optionValuesSCMapping).forEach(key => {\n if (has(options, key)) {\n const updatedValue = optionValuesSCMapping[key][options[key]];\n if (!isUndefined(updatedValue)) {\n convertedOptions[key] = updatedValue;\n }\n }\n });\n return convertedOptions;\n};\n\ninterface y2AxisOptions extends ChartOptions {\n y2Fields?: string | string[];\n}\n\n/**\n * Helper method to process options related to y2Fields\n * @method convertY2AxisOptions\n * @param {Object} originalOptions\n * @returns {Object}\n */\nexport const convertY2AxisOptions = ({\n y2Fields,\n ...originalOptions\n}: y2AxisOptions): Record<string, any> => {\n const convertedOptions: Record<string, any> = {\n ...originalOptions,\n };\n if (y2Fields) {\n convertedOptions['axisY2.enabled'] = true;\n convertedOptions['axisY2.fields'] = isArray(y2Fields)\n ? y2Fields.filter(name => name).join(',')\n : y2Fields;\n }\n return convertedOptions;\n};\n\n/**\n * Helper method to format value for overlayFields\n * @method convertOverlayFields\n * @param {Object} originalOptions\n * @returns {Object}\n */\nexport const convertOverlayFields = (originalOptions: ChartOptions): ChartOptions => {\n const convertedOptions: ChartOptions = {\n ...originalOptions,\n };\n const { overlayFields } = originalOptions;\n if (overlayFields) {\n convertedOptions.overlayFields = Array.isArray(overlayFields)\n ? overlayFields\n .filter(field => field)\n .map(field => field.trim())\n .join(',')\n : overlayFields;\n }\n return convertedOptions;\n};\n\n/**\n * checks whether data is multi series data\n * @param {array} data array\n * @return {Boolean}\n */\nexport const isMultiSeriesData = (data: string[] | string[][]): boolean =>\n Array.isArray(data) && Array.isArray(data[0]);\n/**\n * checks whether data is multi series data and returns value as array\n * @param {array} data array\n * @param {*} value to return as array\n * @return {array}\n */\nexport const toArrayForSeries = (data, value): any[] => (isMultiSeriesData(data) ? value : [value]);\n\ninterface ConstructFieldsAndColumnsParams {\n x: string[];\n y: string[] | string[][];\n xField: string;\n yFields: string | string[];\n y2?: string[] | string[][];\n y2Fields?: string | string[];\n}\nexport const constructFieldsAndColumns = ({\n x = [],\n y = [],\n xField,\n yFields,\n y2,\n y2Fields,\n}: ConstructFieldsAndColumnsParams): JsonColumnData => {\n const columns = [x.map(String), ...toArrayForSeries(y, y).map(series => series.map(String))];\n const yFieldsArray = toArrayForSeries(y, yFields);\n const fields = [{ name: xField }, ...yFieldsArray.map(field => ({ name: field }))];\n // splunk-charting requires y2 to be part of columns\n // when y & y2 options are configured with different (mutually exclusive) series\n // y2 columns need to be added to columns\n if (y2Fields) {\n const y2FieldsArray = toArrayForSeries(y2, y2Fields);\n const y2AsArray = toArrayForSeries(y2, y2).map(series => series?.map(String));\n y2FieldsArray.forEach((y2Field, index) => {\n if (yFieldsArray.indexOf(y2Field) === -1 && y2AsArray[index]) {\n fields.push({\n name: y2Field,\n });\n columns.push(y2AsArray[index]);\n }\n });\n }\n return {\n columns,\n fields,\n };\n};\n"],"sourceRoot":""}
|
package/common/docUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2024 Splunk Inc.
|
|
3
3
|
* SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
|
|
4
4
|
* in part without a valid written license from Splunk Inc. is PROHIBITED.
|
|
5
5
|
*/
|
|
@@ -87,7 +87,7 @@ module.exports =
|
|
|
87
87
|
/******/
|
|
88
88
|
/******/
|
|
89
89
|
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
90
|
+
/******/ return __webpack_require__(__webpack_require__.s = 17);
|
|
91
91
|
/******/ })
|
|
92
92
|
/************************************************************************/
|
|
93
93
|
/******/ ({
|
|
@@ -99,7 +99,7 @@ module.exports = require("react");
|
|
|
99
99
|
|
|
100
100
|
/***/ }),
|
|
101
101
|
|
|
102
|
-
/***/
|
|
102
|
+
/***/ 17:
|
|
103
103
|
/***/ (function(module, exports, __webpack_require__) {
|
|
104
104
|
|
|
105
105
|
"use strict";
|
|
@@ -108,19 +108,25 @@ module.exports = require("react");
|
|
|
108
108
|
Object.defineProperty(exports, "__esModule", {
|
|
109
109
|
value: true
|
|
110
110
|
});
|
|
111
|
-
exports.extractDocItems = exports.getFormatterClassdesc = void 0;
|
|
111
|
+
exports.convertToDashboardJSON = exports.extractDataFromReactCode = exports.formatCodeStringToObject = exports.extractDocItems = exports.getFormatterClassdesc = void 0;
|
|
112
|
+
|
|
112
113
|
var React = __webpack_require__(0);
|
|
113
|
-
|
|
114
|
+
|
|
115
|
+
var UtilPage_1 = __webpack_require__(18);
|
|
116
|
+
|
|
114
117
|
var sharedSelectors = ['getField', 'getType', 'min', 'max'];
|
|
118
|
+
|
|
115
119
|
var formatSidebarItemName = function formatSidebarItemName(name, className) {
|
|
116
120
|
return sharedSelectors.find(function (sharedSelector) {
|
|
117
121
|
return name === sharedSelector;
|
|
118
122
|
}) ? "".concat(className, "#").concat(name) : name;
|
|
119
123
|
};
|
|
124
|
+
|
|
120
125
|
var removePrependedClassName = function removePrependedClassName() {
|
|
121
126
|
var longname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
122
127
|
return longname.slice(longname.indexOf('#') + 1);
|
|
123
128
|
};
|
|
129
|
+
|
|
124
130
|
var formatDSLSelectorDocs = function formatDSLSelectorDocs(docs) {
|
|
125
131
|
return docs.map(function (doc) {
|
|
126
132
|
return Object.assign(Object.assign({}, doc), {
|
|
@@ -128,6 +134,7 @@ var formatDSLSelectorDocs = function formatDSLSelectorDocs(docs) {
|
|
|
128
134
|
});
|
|
129
135
|
});
|
|
130
136
|
};
|
|
137
|
+
|
|
131
138
|
var getFormatterClassdesc = function getFormatterClassdesc(formatterDocs, name) {
|
|
132
139
|
return {
|
|
133
140
|
name: name,
|
|
@@ -136,13 +143,15 @@ var getFormatterClassdesc = function getFormatterClassdesc(formatterDocs, name)
|
|
|
136
143
|
}).classdesc)
|
|
137
144
|
};
|
|
138
145
|
};
|
|
146
|
+
|
|
139
147
|
exports.getFormatterClassdesc = getFormatterClassdesc;
|
|
148
|
+
|
|
140
149
|
var extractDocItems = function extractDocItems(docs, className) {
|
|
141
150
|
var classHeaderDoc = docs[0];
|
|
142
151
|
var fileDoc = docs[docs.length - 1];
|
|
143
152
|
var filteredDocs = formatDSLSelectorDocs(docs).filter(function (_ref) {
|
|
144
153
|
var access = _ref.access,
|
|
145
|
-
|
|
154
|
+
comment = _ref.comment;
|
|
146
155
|
return access === 'public' && comment;
|
|
147
156
|
});
|
|
148
157
|
return filteredDocs.map(function (doc) {
|
|
@@ -161,11 +170,134 @@ var extractDocItems = function extractDocItems(docs, className) {
|
|
|
161
170
|
return a.name.localeCompare(b.name);
|
|
162
171
|
});
|
|
163
172
|
};
|
|
173
|
+
|
|
164
174
|
exports.extractDocItems = extractDocItems;
|
|
165
175
|
|
|
176
|
+
var formatCodeStringToObject = function formatCodeStringToObject(codeString, regexMatch) {
|
|
177
|
+
var match = regexMatch.exec(codeString);
|
|
178
|
+
if (!match) return null;
|
|
179
|
+
var stringToParse = "{".concat(match[1], "}"); // remove trailing commas
|
|
180
|
+
|
|
181
|
+
var removedCommas = stringToParse.replace(/,(?!\s*?[-{["'\w])/g, ''); // convert double quotes (which only occur inside strings) to back quotes
|
|
182
|
+
|
|
183
|
+
var backQuotes = removedCommas.replace(/"/g, '`'); // replace single quotes with double quotes
|
|
184
|
+
|
|
185
|
+
var doubleQuotes = backQuotes.replace(/'/g, '"'); // replace back quotes with single quotes
|
|
186
|
+
|
|
187
|
+
var singleQuotes = doubleQuotes.replace(/`/g, "'"); // add quotes around keys
|
|
188
|
+
|
|
189
|
+
var quotesAroundKeys = singleQuotes.replace(/\b(\w+)\s*:(?=\s)/g, '"$1":');
|
|
190
|
+
var retval = null;
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
retval = JSON.parse(quotesAroundKeys);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
// eslint-disable-next-line no-console
|
|
196
|
+
console.error(e);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return retval;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
exports.formatCodeStringToObject = formatCodeStringToObject;
|
|
203
|
+
|
|
204
|
+
var extractDataFromReactCode = function extractDataFromReactCode(codeString) {
|
|
205
|
+
var _a;
|
|
206
|
+
|
|
207
|
+
var primaryRegex = /dataSources={{([\s\S]*?primary:[\s\S]*?)}}/;
|
|
208
|
+
|
|
209
|
+
var _ref2 = (_a = (0, exports.formatCodeStringToObject)(codeString, primaryRegex)) !== null && _a !== void 0 ? _a : {},
|
|
210
|
+
primary = _ref2.primary;
|
|
211
|
+
|
|
212
|
+
var optionsRegex = /options={{([\s\S]*?)}}/;
|
|
213
|
+
var options = (0, exports.formatCodeStringToObject)(codeString, optionsRegex);
|
|
214
|
+
var contextRegex = /context={{([\s\S]*?)}}/;
|
|
215
|
+
var context = (0, exports.formatCodeStringToObject)(codeString, contextRegex);
|
|
216
|
+
return {
|
|
217
|
+
primary: primary,
|
|
218
|
+
options: options,
|
|
219
|
+
context: context
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
exports.extractDataFromReactCode = extractDataFromReactCode; // Takes a stringified react viz example and a viz type
|
|
224
|
+
// Returns a dashboard definition object.
|
|
225
|
+
// e.g. codeString: '<Area dataSources={{}} options={{}} />'
|
|
226
|
+
// type: 'splunk.area'
|
|
227
|
+
|
|
228
|
+
var convertToDashboardJSON = function convertToDashboardJSON(codeString, type) {
|
|
229
|
+
var _ref3 = (0, exports.extractDataFromReactCode)(codeString),
|
|
230
|
+
options = _ref3.options,
|
|
231
|
+
primary = _ref3.primary,
|
|
232
|
+
context = _ref3.context;
|
|
233
|
+
|
|
234
|
+
return Object.assign(Object.assign({
|
|
235
|
+
visualizations: {
|
|
236
|
+
test_viz: Object.assign(Object.assign(Object.assign({
|
|
237
|
+
type: type
|
|
238
|
+
}, options ? {
|
|
239
|
+
options: options
|
|
240
|
+
} : {}), primary ? {
|
|
241
|
+
dataSources: {
|
|
242
|
+
primary: 'primary'
|
|
243
|
+
}
|
|
244
|
+
} : {}), context ? {
|
|
245
|
+
context: context
|
|
246
|
+
} : {})
|
|
247
|
+
}
|
|
248
|
+
}, primary ? {
|
|
249
|
+
dataSources: {
|
|
250
|
+
primary: {
|
|
251
|
+
type: 'ds.test',
|
|
252
|
+
options: primary
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
} : {}), {
|
|
256
|
+
defaults: {
|
|
257
|
+
dataSources: {
|
|
258
|
+
global: {
|
|
259
|
+
options: {
|
|
260
|
+
queryParameters: {
|
|
261
|
+
latest: '$global_time.latest$',
|
|
262
|
+
earliest: '$global_time.earliest$'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
inputs: {
|
|
269
|
+
input_global_trp: {
|
|
270
|
+
type: 'input.timerange',
|
|
271
|
+
options: {
|
|
272
|
+
token: 'global_time',
|
|
273
|
+
defaultValue: '-24h@h,now'
|
|
274
|
+
},
|
|
275
|
+
title: 'Global Time Range'
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
layout: {
|
|
279
|
+
type: 'absolute',
|
|
280
|
+
options: {},
|
|
281
|
+
structure: [{
|
|
282
|
+
item: 'test_viz',
|
|
283
|
+
type: 'block',
|
|
284
|
+
position: {
|
|
285
|
+
x: 0,
|
|
286
|
+
y: 0,
|
|
287
|
+
w: 800,
|
|
288
|
+
h: 500
|
|
289
|
+
}
|
|
290
|
+
}],
|
|
291
|
+
globalInputs: ['input_global_trp']
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
exports.convertToDashboardJSON = convertToDashboardJSON;
|
|
297
|
+
|
|
166
298
|
/***/ }),
|
|
167
299
|
|
|
168
|
-
/***/
|
|
300
|
+
/***/ 18:
|
|
169
301
|
/***/ (function(module, exports) {
|
|
170
302
|
|
|
171
303
|
module.exports = require("@splunk/react-docs/UtilPage");
|
package/common/docUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"react\"","webpack:///./src/common/docUtils.tsx","webpack:///external \"@splunk/react-docs/UtilPage\""],"names":["React","require","UtilPage_1","sharedSelectors","formatSidebarItemName","name","className","find","sharedSelector","concat","removePrependedClassName","longname","arguments","length","undefined","slice","indexOf","formatDSLSelectorDocs","docs","map","doc","Object","assign","getFormatterClassdesc","formatterDocs","markdown","kind","classdesc","exports","extractDocItems","classHeaderDoc","fileDoc","filteredDocs","filter","_ref","access","comment","component","UtilDoc","createElement","default","title","status","sort","a","b","localeCompare"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,kC;;;;;;;;;;;;;;ACAA,IAAAA,KAAA,GAAAC,mBAAA;AACA,IAAAC,UAAA,GAAAD,mBAAA;AAeA,IAAME,eAAe,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC;AAE7D,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIC,IAAY,EAAEC,SAAiB,EAAY;EACtE,OAAOH,eAAe,CAACI,IAAI,CAAC,UAAAC,cAAc;IAAA,OAAIH,IAAI,KAAKG,cAAc;EAAA,EAAC,MAAAC,MAAA,CAAMH,SAAS,OAAAG,MAAA,CAAIJ,IAAI,IAAKA,IAAI;AAC1G,CAAC;AAED,IAAMK,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAA;EAAA,IAAIC,Q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K,QAAQ,IAAIC,OAAO;EAAA,EAC1D;EAED,OAAOJ,YAAY,CACdb,GAAG,CAAC,UAAAC,GAAG;IAAA,OAAK;MACTf,IAAI,EAAED,qBAAqB,CAACgB,GAAG,CAACf,IAAI,EAAEC,SAAS,CAAC;MAChD+B,SAAS,EAAE,SAASC,OAAOA,CAAA;QACvB;QACA,OACItC,KAAA,CAAAuC,aAAA,CAACrC,UAAA,CAAAsC,OAAQ;UACLC,KAAK,KAAAhC,MAAA,CAAKH,SAAS,OAAAG,MAAA,CAAIW,GAAG,CAACf,IAAI,CAAE;UACjCqC,MAAM,EAAE,CAAC;UACTxB,IAAI,EAAE,CAACY,cAAc,EAAEV,GAAG,EAAEW,OAAO;QAAC,EACtC;MAEV;KACH;EAAA,CAAC,CAAC,CACFY,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC;IAAA,OAAKD,CAAC,CAACvC,IAAI,CAACyC,aAAa,CAACD,CAAC,CAACxC,IAAI,CAAC;EAAA,EAAC;AACrD,CAAC;AAzBYuB,OAAA,CAAAC,eAAe,GAAAA,eAAA,C;;;;;;;ACtC5B,wD","file":"docUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 68);\n","module.exports = require(\"react\");","import * as React from 'react';\nimport UtilPage from '@splunk/react-docs/UtilPage';\n\n// https://github.com/jsdoc2md/jsdoc-api#synopsis\ninterface JsDoc {\n access?: string;\n classdesc?: string;\n comment: string;\n kind: string;\n longname: string;\n meta: Record<string, unknown>;\n member: string;\n name: string;\n scope: string;\n}\n\nconst sharedSelectors = ['getField', 'getType', 'min', 'max'];\n\nconst formatSidebarItemName = (name: string, className: string): string => {\n return sharedSelectors.find(sharedSelector => name === sharedSelector) ? `${className}#${name}` : name;\n};\n\nconst removePrependedClassName = (longname = ''): string => longname.slice(longname.indexOf('#') + 1);\n\nconst formatDSLSelectorDocs = (docs: JsDoc[]): JsDoc[] =>\n docs.map(doc => ({\n ...doc,\n longname: removePrependedClassName(doc.longname),\n }));\n\nexport const getFormatterClassdesc = (\n formatterDocs: JsDoc[],\n name: string\n): { name: string; markdown: string } => ({\n name,\n markdown: `# ${name}\\n ${formatterDocs.find(doc => doc.name === name && doc.kind === 'class').classdesc}`,\n});\n\nexport const extractDocItems = (\n docs: JsDoc[],\n className: string\n): { name: string; component: (...args: any[]) => any }[] => {\n const classHeaderDoc = docs[0];\n const fileDoc = docs[docs.length - 1];\n const filteredDocs = formatDSLSelectorDocs(docs).filter(\n ({ access, comment }) => access === 'public' && comment\n );\n\n return filteredDocs\n .map(doc => ({\n name: formatSidebarItemName(doc.name, className),\n component: function UtilDoc() {\n // named function so linter doesnt raise react/display-name error\n return (\n <UtilPage\n title={`${className}#${doc.name}`}\n status={1}\n docs={[classHeaderDoc, doc, fileDoc]}\n />\n );\n },\n }))\n .sort((a, b) => a.name.localeCompare(b.name));\n};\n","module.exports = require(\"@splunk/react-docs/UtilPage\");"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"react\"","webpack:///./src/common/docUtils.tsx","webpack:///external \"@splunk/react-docs/UtilPage\""],"names":[],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA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AAEI,YAAI,EAAE,OAFV;AAGI,gBAAQ,EAAE;AACN,WAAC,EAAE,CADG;AAEN,WAAC,EAAE,CAFG;AAGN,WAAC,EAAE,GAHG;AAIN,WAAC,EAAE;AAJG;AAHd,OADO,CAHP;AAeJ,kBAAY,EAAE,CAAC,kBAAD;AAfV;AAvB+E,GAT3F;AAkDH,CArDM;;AAAM,iCAAsB,sBAAtB,C;;;;;;;AC/Gb,wD","file":"docUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n","module.exports = require(\"react\");","import * as React from 'react';\nimport UtilPage from '@splunk/react-docs/UtilPage';\n\n// https://github.com/jsdoc2md/jsdoc-api#synopsis\ninterface JsDoc {\n access?: string;\n classdesc?: string;\n comment: string;\n kind: string;\n longname: string;\n meta: Record<string, unknown>;\n member: string;\n name: string;\n scope: string;\n}\n\nconst sharedSelectors = ['getField', 'getType', 'min', 'max'];\n\nconst formatSidebarItemName = (name: string, className: string): string => {\n return sharedSelectors.find(sharedSelector => name === sharedSelector) ? `${className}#${name}` : name;\n};\n\nconst removePrependedClassName = (longname = ''): string => longname.slice(longname.indexOf('#') + 1);\n\nconst formatDSLSelectorDocs = (docs: JsDoc[]): JsDoc[] =>\n docs.map(doc => ({\n ...doc,\n longname: removePrependedClassName(doc.longname),\n }));\n\nexport const getFormatterClassdesc = (\n formatterDocs: JsDoc[],\n name: string\n): { name: string; markdown: string } => ({\n name,\n markdown: `# ${name}\\n ${formatterDocs.find(doc => doc.name === name && doc.kind === 'class').classdesc}`,\n});\n\nexport const extractDocItems = (\n docs: JsDoc[],\n className: string\n): { name: string; component: (...args: any[]) => any }[] => {\n const classHeaderDoc = docs[0];\n const fileDoc = docs[docs.length - 1];\n const filteredDocs = formatDSLSelectorDocs(docs).filter(\n ({ access, comment }) => access === 'public' && comment\n );\n\n return filteredDocs\n .map(doc => ({\n name: formatSidebarItemName(doc.name, className),\n component: function UtilDoc() {\n // named function so linter doesnt raise react/display-name error\n return (\n <UtilPage\n title={`${className}#${doc.name}`}\n status={1}\n docs={[classHeaderDoc, doc, fileDoc]}\n />\n );\n },\n }))\n .sort((a, b) => a.name.localeCompare(b.name));\n};\n\nexport const formatCodeStringToObject = (codeString: string, regexMatch: RegExp): any => {\n const match = regexMatch.exec(codeString);\n if (!match) return null;\n\n const stringToParse = `{${match[1]}}`;\n\n // remove trailing commas\n const removedCommas = stringToParse.replace(/,(?!\\s*?[-{[\"'\\w])/g, '');\n\n // convert double quotes (which only occur inside strings) to back quotes\n const backQuotes = removedCommas.replace(/\"/g, '`');\n // replace single quotes with double quotes\n const doubleQuotes = backQuotes.replace(/'/g, '\"');\n // replace back quotes with single quotes\n const singleQuotes = doubleQuotes.replace(/`/g, \"'\");\n\n // add quotes around keys\n const quotesAroundKeys = singleQuotes.replace(/\\b(\\w+)\\s*:(?=\\s)/g, '\"$1\":');\n\n let retval = null;\n try {\n retval = JSON.parse(quotesAroundKeys);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e);\n }\n return retval;\n};\n\nexport const extractDataFromReactCode = (codeString: string): any => {\n const primaryRegex = /dataSources={{([\\s\\S]*?primary:[\\s\\S]*?)}}/;\n const { primary } = formatCodeStringToObject(codeString, primaryRegex) ?? {};\n\n const optionsRegex = /options={{([\\s\\S]*?)}}/;\n const options = formatCodeStringToObject(codeString, optionsRegex);\n\n const contextRegex = /context={{([\\s\\S]*?)}}/;\n const context = formatCodeStringToObject(codeString, contextRegex);\n\n return { primary, options, context };\n};\n\n// Takes a stringified react viz example and a viz type\n// Returns a dashboard definition object.\n// e.g. codeString: '<Area dataSources={{}} options={{}} />'\n// type: 'splunk.area'\nexport const convertToDashboardJSON = (codeString: string, type: string): any => {\n const { options, primary, context } = extractDataFromReactCode(codeString);\n\n return {\n visualizations: {\n test_viz: {\n type,\n ...(options ? { options } : {}),\n ...(primary ? { dataSources: { primary: 'primary' } } : {}),\n ...(context ? { context } : {}),\n },\n },\n ...(primary ? { dataSources: { primary: { type: 'ds.test', options: primary } } } : {}),\n defaults: {\n dataSources: {\n global: {\n options: {\n queryParameters: {\n latest: '$global_time.latest$',\n earliest: '$global_time.earliest$',\n },\n },\n },\n },\n },\n inputs: {\n input_global_trp: {\n type: 'input.timerange',\n options: {\n token: 'global_time',\n defaultValue: '-24h@h,now',\n },\n title: 'Global Time Range',\n },\n },\n layout: {\n type: 'absolute',\n options: {},\n structure: [\n {\n item: 'test_viz',\n type: 'block',\n position: {\n x: 0,\n y: 0,\n w: 800,\n h: 500,\n },\n },\n ],\n globalInputs: ['input_global_trp'],\n },\n };\n};\n","module.exports = require(\"@splunk/react-docs/UtilPage\");"],"sourceRoot":""}
|