@splunk/visualization-context 25.7.2 → 25.8.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.
@@ -186,31 +186,24 @@ var _geoAssets_world_geo_json__WEBPACK_IMPORTED_MODULE_8___namespace = /*#__PURE
186
186
 
187
187
 
188
188
 
189
-
190
189
  function _createSuper(Derived) {
191
190
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
192
-
193
191
  return function _createSuperInternal() {
194
192
  var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(Derived),
195
- result;
196
-
193
+ result;
197
194
  if (hasNativeReflectConstruct) {
198
195
  var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(this).constructor;
199
-
200
196
  result = Reflect.construct(Super, arguments, NewTarget);
201
197
  } else {
202
198
  result = Super.apply(this, arguments);
203
199
  }
204
-
205
200
  return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, result);
206
201
  };
207
202
  }
208
-
209
203
  function _isNativeReflectConstruct() {
210
204
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
211
205
  if (Reflect.construct.sham) return false;
212
206
  if (typeof Proxy === "function") return true;
213
-
214
207
  try {
215
208
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
216
209
  return true;
@@ -223,56 +216,46 @@ function _isNativeReflectConstruct() {
223
216
 
224
217
 
225
218
 
226
-
227
-
228
-
229
219
  var GeoJsonProvider = /*#__PURE__*/function (_Provider) {
230
220
  _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_2___default()(GeoJsonProvider, _Provider);
231
-
232
221
  var _super = _createSuper(GeoJsonProvider);
233
-
234
222
  function GeoJsonProvider() {
235
223
  _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, GeoJsonProvider);
236
-
237
224
  return _super.call(this);
238
225
  }
226
+
239
227
  /*
240
228
  * return provider type
241
229
  * @return {String} 'geo'
242
230
  */
243
-
244
-
245
231
  _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(GeoJsonProvider, [{
246
232
  key: "getType",
247
233
  value: function getType() {
248
234
  return 'geo';
249
235
  }
236
+
250
237
  /*
251
238
  * getById
252
239
  * Todo: if storageType === 'default', fetch geoJson from s3, else fetch from kvstore in scp provider
253
240
  * @params {Object} config.mapId 'us' or 'world'
254
241
  * @return {Json} USGeoJson or WorldGeoJson
255
242
  */
256
-
257
243
  }, {
258
244
  key: "getById",
259
245
  value: function getById(_ref) {
260
246
  var mapId = _ref.mapId;
261
-
262
247
  if (!mapId) {
263
248
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Invalid mapId.'));
264
249
  }
265
-
266
250
  if (mapId.toLowerCase() === 'us') {
267
251
  return _geoAssets_us_geo_json__WEBPACK_IMPORTED_MODULE_7__;
268
252
  }
269
-
270
253
  if (mapId.toLowerCase() === 'world') {
271
254
  return _geoAssets_world_geo_json__WEBPACK_IMPORTED_MODULE_8__;
272
255
  }
273
-
274
256
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('The geoJson is not found.'));
275
257
  }
258
+
276
259
  /*
277
260
  * Todo: link to storage service in the future
278
261
  * @params {Object} config
@@ -280,14 +263,13 @@ var GeoJsonProvider = /*#__PURE__*/function (_Provider) {
280
263
  * @params {Number} count
281
264
  * @params {Array} [{id: "us", url: 'geo://default/us'}, {id: 'world', url: 'geo://default/world'}]
282
265
  */
283
-
284
266
  }, {
285
267
  key: "listIds",
286
268
  value: function listIds(_ref2) {
287
269
  var _ref2$offset = _ref2.offset,
288
- offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
289
- _ref2$count = _ref2.count,
290
- count = _ref2$count === void 0 ? 100 : _ref2$count;
270
+ offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
271
+ _ref2$count = _ref2.count,
272
+ count = _ref2$count === void 0 ? 100 : _ref2$count;
291
273
  var lists = [{
292
274
  id: 'world',
293
275
  url: 'geo://default/world'
@@ -296,20 +278,20 @@ var GeoJsonProvider = /*#__PURE__*/function (_Provider) {
296
278
  url: 'geo://default/us'
297
279
  }];
298
280
  return lists.slice(offset, offset + count);
299
- } // Todo: be able to upload geoJson in the future
281
+ }
300
282
 
283
+ // Todo: be able to upload geoJson in the future
301
284
  }, {
302
285
  key: "upload",
303
- value: function upload() {} // Todo: be able to delete geoJson in the future
286
+ value: function upload() {}
304
287
 
288
+ // Todo: be able to delete geoJson in the future
305
289
  }, {
306
290
  key: "deleteById",
307
291
  value: function deleteById() {}
308
292
  }]);
309
-
310
293
  return GeoJsonProvider;
311
294
  }(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6___default.a);
312
-
313
295
  /* harmony default export */ __webpack_exports__["default"] = (GeoJsonProvider);
314
296
 
315
297
  /***/ })
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///./src/GeoJsonProvider.js"],"names":["GeoJsonProvider","mapId","_","offset","count","lists","id","url","Provider"],"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/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,CAALA,cAAoBF,MAAM,GAAjC,KAAOE,CAAP;MAGJ;;;;WACA,kBAAS,C,EAET;;;;WACA,sBAAa,CAAE;;;;EA5DWG,6E;;AA+D9B,gF","file":"GeoJsonProvider.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 = 22);\n","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@splunk/visualization-context/Provider\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","/* eslint-disable class-methods-use-this,no-useless-constructor */\nimport { _ } from '@splunk/ui-utils/i18n';\nimport Provider from '@splunk/visualization-context/Provider';\nimport USGeoJson from './geoAssets/us.geo.json';\nimport WorldGeoJson from './geoAssets/world.geo.json';\n\nclass GeoJsonProvider extends Provider {\n constructor() {\n super();\n }\n\n /*\n * return provider type\n * @return {String} 'geo'\n */\n getType() {\n return 'geo';\n }\n\n /*\n * getById\n * Todo: if storageType === 'default', fetch geoJson from s3, else fetch from kvstore in scp provider\n * @params {Object} config.mapId 'us' or 'world'\n * @return {Json} USGeoJson or WorldGeoJson\n */\n getById({ mapId }) {\n if (!mapId) {\n throw new Error(_('Invalid mapId.'));\n }\n\n if (mapId.toLowerCase() === 'us') {\n return USGeoJson;\n }\n if (mapId.toLowerCase() === 'world') {\n return WorldGeoJson;\n }\n\n throw new Error(_('The geoJson is not found.'));\n }\n\n /*\n * Todo: link to storage service in the future\n * @params {Object} config\n * @params {Number} offset\n * @params {Number} count\n * @params {Array} [{id: \"us\", url: 'geo://default/us'}, {id: 'world', url: 'geo://default/world'}]\n */\n listIds({ offset = 0, count = 100 }) {\n const lists = [\n {\n id: 'world',\n url: 'geo://default/world',\n },\n {\n id: 'us',\n url: 'geo://default/us',\n },\n ];\n\n return lists.slice(offset, offset + count);\n }\n\n // Todo: be able to upload geoJson in the future\n upload() {}\n\n // Todo: be able to delete geoJson in the future\n deleteById() {}\n}\n\nexport default GeoJsonProvider;\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/ui-utils/i18n\"","webpack:///external \"@babel/runtime/helpers/classCallCheck\"","webpack:///external \"@babel/runtime/helpers/createClass\"","webpack:///external \"@babel/runtime/helpers/getPrototypeOf\"","webpack:///external \"@splunk/visualization-context/Provider\"","webpack:///external \"@babel/runtime/helpers/inherits\"","webpack:///external \"@babel/runtime/helpers/possibleConstructorReturn\"","webpack:///./src/GeoJsonProvider.js"],"names":["GeoJsonProvider","_Provider","_inherits","_super","_createSuper","_classCallCheck","call","_createClass","key","value","getType","getById","_ref","mapId","Error","_","toLowerCase","USGeoJson","WorldGeoJson","listIds","_ref2","_ref2$offset","offset","_ref2$count","count","lists","id","url","slice","upload","deleteById","Provider"],"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;QAC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2BAA2B,CAAC,CAAC;IACnD;;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EANI;IAAAP,GAAA;IAAAC,KAAA,EAOA,SAAAU,QAAAC,KAAA,EAAqC;MAAA,IAAAC,YAAA,GAAAD,KAAA,CAA3BE,MAAM;QAANA,MAAM,GAAAD,YAAA,cAAG,CAAC,GAAAA,YAAA;QAAAE,WAAA,GAAAH,KAAA,CAAEI,KAAK;QAALA,KAAK,GAAAD,WAAA,cAAG,GAAG,GAAAA,WAAA;MAC7B,IAAME,KAAK,GAAG,CACV;QACIC,EAAE,EAAE,OAAO;QACXC,GAAG,EAAE;MACT,CAAC,EACD;QACID,EAAE,EAAE,IAAI;QACRC,GAAG,EAAE;MACT,CAAC,CACJ;MAED,OAAOF,KAAK,CAACG,KAAK,CAACN,MAAM,EAAEA,MAAM,GAAGE,KAAK,CAAC;IAC9C;;IAEA;EAAA;IAAAhB,GAAA;IAAAC,KAAA,EACA,SAAAoB,OAAA,EAAS,CAAC;;IAEV;EAAA;IAAArB,GAAA;IAAAC,KAAA,EACA,SAAAqB,WAAA,EAAa,CAAC;EAAC;EAAA,OAAA9B,eAAA;AAAA,EA5DW+B,6EAAQ;AA+DvB/B,8EAAe,E","file":"GeoJsonProvider.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 = 22);\n","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@babel/runtime/helpers/classCallCheck\");","module.exports = require(\"@babel/runtime/helpers/createClass\");","module.exports = require(\"@babel/runtime/helpers/getPrototypeOf\");","module.exports = require(\"@splunk/visualization-context/Provider\");","module.exports = require(\"@babel/runtime/helpers/inherits\");","module.exports = require(\"@babel/runtime/helpers/possibleConstructorReturn\");","/* eslint-disable class-methods-use-this,no-useless-constructor */\nimport { _ } from '@splunk/ui-utils/i18n';\nimport Provider from '@splunk/visualization-context/Provider';\nimport USGeoJson from './geoAssets/us.geo.json';\nimport WorldGeoJson from './geoAssets/world.geo.json';\n\nclass GeoJsonProvider extends Provider {\n constructor() {\n super();\n }\n\n /*\n * return provider type\n * @return {String} 'geo'\n */\n getType() {\n return 'geo';\n }\n\n /*\n * getById\n * Todo: if storageType === 'default', fetch geoJson from s3, else fetch from kvstore in scp provider\n * @params {Object} config.mapId 'us' or 'world'\n * @return {Json} USGeoJson or WorldGeoJson\n */\n getById({ mapId }) {\n if (!mapId) {\n throw new Error(_('Invalid mapId.'));\n }\n\n if (mapId.toLowerCase() === 'us') {\n return USGeoJson;\n }\n if (mapId.toLowerCase() === 'world') {\n return WorldGeoJson;\n }\n\n throw new Error(_('The geoJson is not found.'));\n }\n\n /*\n * Todo: link to storage service in the future\n * @params {Object} config\n * @params {Number} offset\n * @params {Number} count\n * @params {Array} [{id: \"us\", url: 'geo://default/us'}, {id: 'world', url: 'geo://default/world'}]\n */\n listIds({ offset = 0, count = 100 }) {\n const lists = [\n {\n id: 'world',\n url: 'geo://default/world',\n },\n {\n id: 'us',\n url: 'geo://default/us',\n },\n ];\n\n return lists.slice(offset, offset + count);\n }\n\n // Todo: be able to upload geoJson in the future\n upload() {}\n\n // Todo: be able to delete geoJson in the future\n deleteById() {}\n}\n\nexport default GeoJsonProvider;\n"],"sourceRoot":""}
package/GeoRegistry.js CHANGED
@@ -184,15 +184,12 @@ __webpack_require__.r(__webpack_exports__);
184
184
  /**
185
185
  * Base Registry
186
186
  */
187
-
188
187
  var BaseRegistry = /*#__PURE__*/function () {
189
188
  function BaseRegistry() {
190
189
  _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, BaseRegistry);
191
-
192
190
  this.cachedProviders = {};
193
191
  this.defaultProvider = null;
194
192
  }
195
-
196
193
  _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default()(BaseRegistry, [{
197
194
  key: "isValidProvider",
198
195
  value:
@@ -205,14 +202,13 @@ var BaseRegistry = /*#__PURE__*/function () {
205
202
  if (provider instanceof _splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6___default.a) {
206
203
  return true;
207
204
  }
208
-
209
205
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Invalid Provider'));
210
206
  }
207
+
211
208
  /**
212
209
  * add default provider to cache
213
210
  * @param {Provider} provider
214
211
  */
215
-
216
212
  }, {
217
213
  key: "addDefaultProvider",
218
214
  value: function addDefaultProvider(provider) {
@@ -221,11 +217,11 @@ var BaseRegistry = /*#__PURE__*/function () {
221
217
  this.defaultProvider = provider;
222
218
  }
223
219
  }
220
+
224
221
  /**
225
222
  * add provider to cache
226
223
  * @param {Provider} provider
227
224
  */
228
-
229
225
  }, {
230
226
  key: "addProvider",
231
227
  value: function addProvider(provider) {
@@ -234,59 +230,52 @@ var BaseRegistry = /*#__PURE__*/function () {
234
230
  // eslint-disable-next-line
235
231
  console.warn("The provider \"".concat(provider.getType(), "\" existed already."));
236
232
  }
237
-
238
233
  this.cachedProviders[provider.getType()] = provider;
239
234
  }
240
235
  }
236
+
241
237
  /**
242
238
  * delete provider
243
239
  * @param {String} providerType
244
240
  */
245
-
246
241
  }, {
247
242
  key: "deleteProvider",
248
243
  value: function deleteProvider(providerType) {
249
244
  var cachedProvider = this.cachedProviders[providerType];
250
-
251
245
  if (!cachedProvider) {
252
246
  // eslint-disable-next-line
253
247
  console.warn("The provider \"".concat(providerType, "\" does not existed"));
254
248
  return;
255
249
  }
256
-
257
250
  if (this.defaultProvider && providerType === this.defaultProvider.getType()) {
258
251
  this.defaultProvider = null;
259
252
  }
260
-
261
253
  delete this.cachedProviders[providerType];
262
254
  }
255
+
263
256
  /**
264
257
  * find provider from cache
265
258
  * @param {String} type
266
259
  * @returns {Provider} provider
267
260
  */
268
-
269
261
  }, {
270
262
  key: "findProvider",
271
263
  value: function findProvider(type) {
272
264
  var provider = this.cachedProviders[type];
273
-
274
265
  if (provider) {
275
266
  return provider;
276
267
  }
277
-
278
268
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Provider not found'));
279
269
  }
270
+
280
271
  /**
281
272
  * list all providers
282
273
  * @return {Object} provider = { type: 'local', isDefault: true }
283
274
  */
284
-
285
275
  }, {
286
276
  key: "listProviders",
287
277
  value: function listProviders() {
288
278
  var _this = this;
289
-
290
279
  return Object.keys(this.cachedProviders).map(function (type) {
291
280
  return {
292
281
  type: type,
@@ -294,22 +283,21 @@ var BaseRegistry = /*#__PURE__*/function () {
294
283
  };
295
284
  });
296
285
  }
286
+
297
287
  /**
298
288
  * check whether src is a http url or a url used for icon/image-registry (e.g. 'kvstore://image123')
299
289
  */
300
-
301
290
  }, {
302
291
  key: "isResourceURL",
303
292
  value: function isResourceURL(url) {
304
293
  if (!url || url.indexOf('://') < 0) {
305
294
  return false;
306
295
  }
307
-
308
296
  var _this$parseURL = this.parseURL(url),
309
- type = _this$parseURL.type;
310
-
297
+ type = _this$parseURL.type;
311
298
  return type !== 'http' && type !== 'https';
312
299
  }
300
+
313
301
  /**
314
302
  * parse provider type and id from the url
315
303
  * @params {String} url 'kvstore://image123'
@@ -317,16 +305,14 @@ var BaseRegistry = /*#__PURE__*/function () {
317
305
  * @returns {String} obj.type 'kvstore'
318
306
  * @returns {String} obj.id 'image123'
319
307
  */
320
-
321
308
  }, {
322
309
  key: "parseURL",
323
310
  value: function parseURL(url) {
324
311
  if (url) {
325
312
  var _url$split = url.split('://'),
326
- _url$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_url$split, 2),
327
- type = _url$split2[0],
328
- id = _url$split2[1];
329
-
313
+ _url$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_url$split, 2),
314
+ type = _url$split2[0],
315
+ id = _url$split2[1];
330
316
  if (type && id) {
331
317
  return {
332
318
  type: type,
@@ -334,9 +320,9 @@ var BaseRegistry = /*#__PURE__*/function () {
334
320
  };
335
321
  }
336
322
  }
337
-
338
323
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Invalid url'));
339
324
  }
325
+
340
326
  /**
341
327
  * upload
342
328
  * @param {DataURI} dataURI
@@ -344,7 +330,6 @@ var BaseRegistry = /*#__PURE__*/function () {
344
330
  * @param {String} providerType e.g. 'kvstore' or 'sui' or 'local'
345
331
  * @returns {String} id e.g. 'kvstore://image123'
346
332
  */
347
-
348
333
  }, {
349
334
  key: "upload",
350
335
  value: function () {
@@ -358,18 +343,14 @@ var BaseRegistry = /*#__PURE__*/function () {
358
343
  _context.next = 2;
359
344
  break;
360
345
  }
361
-
362
346
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('No valid provider was found. Please add a provider'));
363
-
364
347
  case 2:
365
348
  provider = providerType ? this.findProvider(providerType) : this.defaultProvider;
366
349
  _context.next = 5;
367
350
  return provider.upload(dataURI, metaData);
368
-
369
351
  case 5:
370
352
  id = _context.sent;
371
353
  return _context.abrupt("return", "".concat(provider.getType(), "://").concat(id));
372
-
373
354
  case 7:
374
355
  case "end":
375
356
  return _context.stop();
@@ -377,11 +358,9 @@ var BaseRegistry = /*#__PURE__*/function () {
377
358
  }
378
359
  }, _callee, this);
379
360
  }));
380
-
381
361
  function upload(_x, _x2, _x3) {
382
362
  return _upload.apply(this, arguments);
383
363
  }
384
-
385
364
  return upload;
386
365
  }()
387
366
  /**
@@ -389,13 +368,11 @@ var BaseRegistry = /*#__PURE__*/function () {
389
368
  * @param {String} url 'kvstore://image123'
390
369
  * @returns {Object} obj e.g. an image object or icon
391
370
  */
392
-
393
371
  }, {
394
372
  key: "getByURL",
395
373
  value: function () {
396
374
  var _getByURL = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.mark(function _callee2(url) {
397
375
  var _this$parseURL2, type, id, provider, obj;
398
-
399
376
  return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee2$(_context2) {
400
377
  while (1) {
401
378
  switch (_context2.prev = _context2.next) {
@@ -404,11 +381,9 @@ var BaseRegistry = /*#__PURE__*/function () {
404
381
  provider = this.findProvider(type);
405
382
  _context2.next = 4;
406
383
  return provider.getById(id);
407
-
408
384
  case 4:
409
385
  obj = _context2.sent;
410
386
  return _context2.abrupt("return", obj);
411
-
412
387
  case 6:
413
388
  case "end":
414
389
  return _context2.stop();
@@ -416,11 +391,9 @@ var BaseRegistry = /*#__PURE__*/function () {
416
391
  }
417
392
  }, _callee2, this);
418
393
  }));
419
-
420
394
  function getByURL(_x4) {
421
395
  return _getByURL.apply(this, arguments);
422
396
  }
423
-
424
397
  return getByURL;
425
398
  }()
426
399
  /**
@@ -428,13 +401,11 @@ var BaseRegistry = /*#__PURE__*/function () {
428
401
  * @param {String} url 'kvstore://image123' || 'sui://icon123'
429
402
  * @returns {Object} obj e.g. an image object or icon
430
403
  */
431
-
432
404
  }, {
433
405
  key: "deleteByURL",
434
406
  value: function () {
435
407
  var _deleteByURL = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.mark(function _callee3(url) {
436
408
  var _this$parseURL3, type, id, provider, obj;
437
-
438
409
  return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee3$(_context3) {
439
410
  while (1) {
440
411
  switch (_context3.prev = _context3.next) {
@@ -443,11 +414,9 @@ var BaseRegistry = /*#__PURE__*/function () {
443
414
  provider = this.findProvider(type);
444
415
  _context3.next = 4;
445
416
  return provider.deleteById(id);
446
-
447
417
  case 4:
448
418
  obj = _context3.sent;
449
419
  return _context3.abrupt("return", obj);
450
-
451
420
  case 6:
452
421
  case "end":
453
422
  return _context3.stop();
@@ -455,11 +424,9 @@ var BaseRegistry = /*#__PURE__*/function () {
455
424
  }
456
425
  }, _callee3, this);
457
426
  }));
458
-
459
427
  function deleteByURL(_x5) {
460
428
  return _deleteByURL.apply(this, arguments);
461
429
  }
462
-
463
430
  return deleteByURL;
464
431
  }()
465
432
  /**
@@ -468,15 +435,14 @@ var BaseRegistry = /*#__PURE__*/function () {
468
435
  * @params {Object} options
469
436
  * @returns {Array} ids
470
437
  */
471
-
472
438
  }, {
473
439
  key: "listIds",
474
440
  value: function () {
475
441
  var _listIds = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.mark(function _callee4(providerType) {
476
442
  var options,
477
- provider,
478
- ids,
479
- _args4 = arguments;
443
+ provider,
444
+ ids,
445
+ _args4 = arguments;
480
446
  return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee4$(_context4) {
481
447
  while (1) {
482
448
  switch (_context4.prev = _context4.next) {
@@ -488,11 +454,9 @@ var BaseRegistry = /*#__PURE__*/function () {
488
454
  provider = this.findProvider(providerType);
489
455
  _context4.next = 4;
490
456
  return provider.listIds(options);
491
-
492
457
  case 4:
493
458
  ids = _context4.sent;
494
459
  return _context4.abrupt("return", ids);
495
-
496
460
  case 6:
497
461
  case "end":
498
462
  return _context4.stop();
@@ -500,11 +464,9 @@ var BaseRegistry = /*#__PURE__*/function () {
500
464
  }
501
465
  }, _callee4, this);
502
466
  }));
503
-
504
467
  function listIds(_x6) {
505
468
  return _listIds.apply(this, arguments);
506
469
  }
507
-
508
470
  return listIds;
509
471
  }()
510
472
  }], [{
@@ -513,10 +475,8 @@ var BaseRegistry = /*#__PURE__*/function () {
513
475
  return new BaseRegistry();
514
476
  }
515
477
  }]);
516
-
517
478
  return BaseRegistry;
518
479
  }();
519
-
520
480
  /* harmony default export */ __webpack_exports__["default"] = (BaseRegistry);
521
481
 
522
482
  /***/ }),
@@ -556,31 +516,24 @@ __webpack_require__.r(__webpack_exports__);
556
516
 
557
517
 
558
518
 
559
-
560
519
  function _createSuper(Derived) {
561
520
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
562
-
563
521
  return function _createSuperInternal() {
564
522
  var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
565
- result;
566
-
523
+ result;
567
524
  if (hasNativeReflectConstruct) {
568
525
  var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
569
-
570
526
  result = Reflect.construct(Super, arguments, NewTarget);
571
527
  } else {
572
528
  result = Super.apply(this, arguments);
573
529
  }
574
-
575
530
  return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
576
531
  };
577
532
  }
578
-
579
533
  function _isNativeReflectConstruct() {
580
534
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
581
535
  if (Reflect.construct.sham) return false;
582
536
  if (typeof Proxy === "function") return true;
583
-
584
537
  try {
585
538
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
586
539
  return true;
@@ -591,20 +544,13 @@ function _isNativeReflectConstruct() {
591
544
  /* eslint-disable class-methods-use-this */
592
545
 
593
546
 
594
-
595
-
596
-
597
547
  var GeoRegistry = /*#__PURE__*/function (_BaseRegistry) {
598
548
  _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(GeoRegistry, _BaseRegistry);
599
-
600
549
  var _super = _createSuper(GeoRegistry);
601
-
602
550
  function GeoRegistry() {
603
551
  _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, GeoRegistry);
604
-
605
552
  return _super.apply(this, arguments);
606
553
  }
607
-
608
554
  _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(GeoRegistry, [{
609
555
  key: "parseURL",
610
556
  value:
@@ -620,38 +566,34 @@ var GeoRegistry = /*#__PURE__*/function (_BaseRegistry) {
620
566
  if (!/.+:\/\/.*\/.+/.test(url)) {
621
567
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('Invalid url.'));
622
568
  }
623
-
624
569
  var _url$split = url.split('://'),
625
- _url$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_url$split, 2),
626
- providerType = _url$split2[0],
627
- geoId = _url$split2[1];
628
-
570
+ _url$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_url$split, 2),
571
+ providerType = _url$split2[0],
572
+ geoId = _url$split2[1];
629
573
  var _geoId$split = geoId.split('/'),
630
- _geoId$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_geoId$split, 2),
631
- storageType = _geoId$split2[0],
632
- mapId = _geoId$split2[1];
633
-
574
+ _geoId$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_geoId$split, 2),
575
+ storageType = _geoId$split2[0],
576
+ mapId = _geoId$split2[1];
634
577
  return {
635
578
  providerType: providerType,
636
579
  storageType: storageType,
637
580
  mapId: mapId
638
581
  };
639
582
  }
583
+
640
584
  /*
641
585
  * get geoJson by url
642
586
  * @params {String} url e.g. geo://default/us
643
587
  * @return {Json} geoJson
644
588
  */
645
-
646
589
  }, {
647
590
  key: "getByURL",
648
591
  value: function getByURL(url) {
649
592
  try {
650
593
  var _this$parseURL = this.parseURL(url),
651
- providerType = _this$parseURL.providerType,
652
- storageType = _this$parseURL.storageType,
653
- mapId = _this$parseURL.mapId;
654
-
594
+ providerType = _this$parseURL.providerType,
595
+ storageType = _this$parseURL.storageType,
596
+ mapId = _this$parseURL.mapId;
655
597
  var provider = this.findProvider(providerType);
656
598
  var geoJson = provider.getById({
657
599
  storageType: storageType,
@@ -661,8 +603,9 @@ var GeoRegistry = /*#__PURE__*/function (_BaseRegistry) {
661
603
  } catch (error) {
662
604
  throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('Cannot get geoJson data.'));
663
605
  }
664
- } // Todo: return map ids from storage
606
+ }
665
607
 
608
+ // Todo: return map ids from storage
666
609
  /*
667
610
  * list all available geojson ids
668
611
  * @params {Object}
@@ -670,26 +613,27 @@ var GeoRegistry = /*#__PURE__*/function (_BaseRegistry) {
670
613
  * @params {Object} options
671
614
  * @return {Array} ids [{id: "us", url: 'geo://default/us'}, {id: 'world', url: 'geo://default/world'}]
672
615
  */
673
-
674
616
  }, {
675
617
  key: "listIds",
676
618
  value: function listIds(_ref) {
677
619
  var _ref$providerType = _ref.providerType,
678
- providerType = _ref$providerType === void 0 ? 'geo' : _ref$providerType,
679
- _ref$options = _ref.options,
680
- options = _ref$options === void 0 ? {
681
- offset: 0,
682
- count: 100
683
- } : _ref$options;
620
+ providerType = _ref$providerType === void 0 ? 'geo' : _ref$providerType,
621
+ _ref$options = _ref.options,
622
+ options = _ref$options === void 0 ? {
623
+ offset: 0,
624
+ count: 100
625
+ } : _ref$options;
684
626
  var provider = this.findProvider(providerType);
685
627
  var ids = provider.listIds(options);
686
628
  return ids;
687
- } // Todo: be able to upload geoJson in the future
629
+ }
688
630
 
631
+ // Todo: be able to upload geoJson in the future
689
632
  }, {
690
633
  key: "upload",
691
- value: function upload() {} // Todo: be able to delete geoJson in the future
634
+ value: function upload() {}
692
635
 
636
+ // Todo: be able to delete geoJson in the future
693
637
  }, {
694
638
  key: "deleteByURL",
695
639
  value: function deleteByURL() {}
@@ -699,10 +643,8 @@ var GeoRegistry = /*#__PURE__*/function (_BaseRegistry) {
699
643
  return new GeoRegistry();
700
644
  }
701
645
  }]);
702
-
703
646
  return GeoRegistry;
704
647
  }(_BaseRegistry__WEBPACK_IMPORTED_MODULE_7__["default"]);
705
-
706
648
  /* harmony default export */ __webpack_exports__["default"] = (GeoRegistry);
707
649
 
708
650
  /***/ })