@splunk/visualization-context 26.4.0 → 27.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/BaseRegistry.js +227 -495
  2. package/BaseRegistry.js.map +7 -1
  3. package/DataSourceContext.js +55 -125
  4. package/DataSourceContext.js.map +7 -1
  5. package/EventsContext.js +54 -121
  6. package/EventsContext.js.map +7 -1
  7. package/FeatureFlagContext.js +55 -120
  8. package/FeatureFlagContext.js.map +7 -1
  9. package/FeatureFlags.js +27 -107
  10. package/FeatureFlags.js.map +7 -1
  11. package/GeoContext.js +55 -120
  12. package/GeoContext.js.map +7 -1
  13. package/GeoJsonProvider.js +26712 -303
  14. package/GeoJsonProvider.js.map +7 -1
  15. package/GeoRegistry.js +280 -691
  16. package/GeoRegistry.js.map +7 -1
  17. package/IconContext.js +55 -120
  18. package/IconContext.js.map +7 -1
  19. package/IconRegistry.js +256 -654
  20. package/IconRegistry.js.map +7 -1
  21. package/ImageContext.js +55 -120
  22. package/ImageContext.js.map +7 -1
  23. package/ImageRegistry.js +265 -660
  24. package/ImageRegistry.js.map +7 -1
  25. package/LocalIconProvider.js +206 -470
  26. package/LocalIconProvider.js.map +7 -1
  27. package/LocalImageProvider.js +143 -366
  28. package/LocalImageProvider.js.map +7 -1
  29. package/MapContext.js +103 -164
  30. package/MapContext.js.map +7 -1
  31. package/MessageContext.js +54 -121
  32. package/MessageContext.js.map +7 -1
  33. package/MockedProvider.js +146 -376
  34. package/MockedProvider.js.map +7 -1
  35. package/Provider.js +87 -276
  36. package/Provider.js.map +7 -1
  37. package/TimezoneContext.js +55 -122
  38. package/TimezoneContext.js.map +7 -1
  39. package/package.json +7 -14
  40. package/testDataURIs.js +37 -106
  41. package/testDataURIs.js.map +7 -1
  42. package/testSVG.js +27 -104
  43. package/testSVG.js.map +7 -1
  44. package/babel.config.js +0 -3
package/BaseRegistry.js CHANGED
@@ -1,509 +1,241 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 12);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ([
94
- /* 0 */
95
- /***/ (function(module, exports) {
96
-
97
- module.exports = require("@splunk/ui-utils/i18n");
98
-
99
- /***/ }),
100
- /* 1 */
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("@babel/runtime/regenerator");
104
-
105
- /***/ }),
106
- /* 2 */
107
- /***/ (function(module, exports) {
108
-
109
- module.exports = require("@babel/runtime/helpers/classCallCheck");
110
-
111
- /***/ }),
112
- /* 3 */
113
- /***/ (function(module, exports) {
114
-
115
- module.exports = require("@babel/runtime/helpers/createClass");
116
-
117
- /***/ }),
118
- /* 4 */
119
- /***/ (function(module, exports) {
120
-
121
- module.exports = require("@babel/runtime/helpers/asyncToGenerator");
122
-
123
- /***/ }),
124
- /* 5 */,
125
- /* 6 */
126
- /***/ (function(module, exports) {
127
-
128
- module.exports = require("@splunk/visualization-context/Provider");
129
-
130
- /***/ }),
131
- /* 7 */,
132
- /* 8 */,
133
- /* 9 */,
134
- /* 10 */,
135
- /* 11 */
136
- /***/ (function(module, exports) {
137
-
138
- module.exports = require("@babel/runtime/helpers/slicedToArray");
139
-
140
- /***/ }),
141
- /* 12 */
142
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
143
-
144
- "use strict";
145
- __webpack_require__.r(__webpack_exports__);
146
- /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
147
- /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
148
- /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
149
- /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__);
150
- /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
151
- /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__);
152
- /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
153
- /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__);
154
- /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
155
- /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4__);
156
- /* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(0);
157
- /* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__);
158
- /* harmony import */ var _splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6);
159
- /* harmony import */ var _splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6__);
160
-
161
-
162
-
163
-
164
-
165
- /* eslint-disable class-methods-use-this */
166
-
167
-
168
-
169
- /**
170
- * Base Registry
171
- */
172
-
173
- var BaseRegistry = /*#__PURE__*/function () {
174
- function BaseRegistry() {
175
- _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, BaseRegistry);
176
-
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
52
+
53
+ // src/BaseRegistry.js
54
+ var BaseRegistry_exports = {};
55
+ __export(BaseRegistry_exports, {
56
+ default: () => BaseRegistry_default
57
+ });
58
+ module.exports = __toCommonJS(BaseRegistry_exports);
59
+
60
+ // esm-externals:@splunk/ui-utils/i18n
61
+ var i18n_exports = {};
62
+ __export(i18n_exports, {
63
+ default: () => i18n_default
64
+ });
65
+ var defaultImport = __toESM(require("@splunk/ui-utils/i18n"));
66
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
67
+ var i18n_default = "default" in defaultImport ? defaultImport.default : defaultImport;
68
+
69
+ // esm-externals:@splunk/visualization-context/Provider
70
+ var Provider_exports = {};
71
+ __export(Provider_exports, {
72
+ default: () => Provider_default
73
+ });
74
+ var defaultImport2 = __toESM(require("@splunk/visualization-context/Provider"));
75
+ __reExport(Provider_exports, require("@splunk/visualization-context/Provider"));
76
+ var Provider_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
77
+
78
+ // src/BaseRegistry.js
79
+ var BaseRegistry = class _BaseRegistry {
80
+ constructor() {
177
81
  this.cachedProviders = {};
178
82
  this.defaultProvider = null;
179
83
  }
180
-
181
- _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3___default()(BaseRegistry, [{
182
- key: "isValidProvider",
183
- value:
184
- /**
185
- * check whether user defined provider extends the base provider
186
- * @param {Provider} provider
187
- * @returns {Boolean}
188
- */
189
- function isValidProvider(provider) {
190
- if (provider instanceof _splunk_visualization_context_Provider__WEBPACK_IMPORTED_MODULE_6___default.a) {
191
- return true;
192
- }
193
-
194
- throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Invalid Provider'));
84
+ static create() {
85
+ return new _BaseRegistry();
86
+ }
87
+ /**
88
+ * check whether user defined provider extends the base provider
89
+ * @param {Provider} provider
90
+ * @returns {Boolean}
91
+ */
92
+ isValidProvider(provider) {
93
+ if (provider instanceof Provider_default) {
94
+ return true;
195
95
  }
196
- /**
197
- * add default provider to cache
198
- * @param {Provider} provider
199
- */
200
-
201
- }, {
202
- key: "addDefaultProvider",
203
- value: function addDefaultProvider(provider) {
204
- if (this.isValidProvider(provider)) {
205
- this.addProvider(provider);
206
- this.defaultProvider = provider;
207
- }
96
+ throw new Error((0, i18n_exports._)("Invalid Provider"));
97
+ }
98
+ /**
99
+ * add default provider to cache
100
+ * @param {Provider} provider
101
+ */
102
+ addDefaultProvider(provider) {
103
+ if (this.isValidProvider(provider)) {
104
+ this.addProvider(provider);
105
+ this.defaultProvider = provider;
208
106
  }
209
- /**
210
- * add provider to cache
211
- * @param {Provider} provider
212
- */
213
-
214
- }, {
215
- key: "addProvider",
216
- value: function addProvider(provider) {
217
- if (this.isValidProvider(provider)) {
218
- if (this.cachedProviders[provider.getType()]) {
219
- // eslint-disable-next-line
220
- console.warn("The provider \"".concat(provider.getType(), "\" existed already."));
221
- }
222
-
223
- this.cachedProviders[provider.getType()] = provider;
107
+ }
108
+ /**
109
+ * add provider to cache
110
+ * @param {Provider} provider
111
+ */
112
+ addProvider(provider) {
113
+ if (this.isValidProvider(provider)) {
114
+ if (this.cachedProviders[provider.getType()]) {
115
+ console.warn(`The provider "${provider.getType()}" existed already.`);
224
116
  }
117
+ this.cachedProviders[provider.getType()] = provider;
225
118
  }
226
- /**
227
- * delete provider
228
- * @param {String} providerType
229
- */
230
-
231
- }, {
232
- key: "deleteProvider",
233
- value: function deleteProvider(providerType) {
234
- var cachedProvider = this.cachedProviders[providerType];
235
-
236
- if (!cachedProvider) {
237
- // eslint-disable-next-line
238
- console.warn("The provider \"".concat(providerType, "\" does not existed"));
239
- return;
240
- }
241
-
242
- if (this.defaultProvider && providerType === this.defaultProvider.getType()) {
243
- this.defaultProvider = null;
244
- }
245
-
246
- delete this.cachedProviders[providerType];
119
+ }
120
+ /**
121
+ * delete provider
122
+ * @param {String} providerType
123
+ */
124
+ deleteProvider(providerType) {
125
+ const cachedProvider = this.cachedProviders[providerType];
126
+ if (!cachedProvider) {
127
+ console.warn(`The provider "${providerType}" does not existed`);
128
+ return;
247
129
  }
248
- /**
249
- * find provider from cache
250
- * @param {String} type
251
- * @returns {Provider} provider
252
- */
253
-
254
- }, {
255
- key: "findProvider",
256
- value: function findProvider(type) {
257
- var provider = this.cachedProviders[type];
258
-
259
- if (provider) {
260
- return provider;
261
- }
262
-
263
- throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Provider not found'));
130
+ if (this.defaultProvider && providerType === this.defaultProvider.getType()) {
131
+ this.defaultProvider = null;
264
132
  }
265
- /**
266
- * list all providers
267
- * @return {Object} provider = { type: 'local', isDefault: true }
268
- */
269
-
270
- }, {
271
- key: "listProviders",
272
- value: function listProviders() {
273
- var _this = this;
274
-
275
- return Object.keys(this.cachedProviders).map(function (type) {
276
- return {
277
- type: type,
278
- isDefault: type === _this.defaultProvider.getType()
279
- };
280
- });
133
+ delete this.cachedProviders[providerType];
134
+ }
135
+ /**
136
+ * find provider from cache
137
+ * @param {String} type
138
+ * @returns {Provider} provider
139
+ */
140
+ findProvider(type) {
141
+ const provider = this.cachedProviders[type];
142
+ if (provider) {
143
+ return provider;
281
144
  }
282
- /**
283
- * check whether src is a http url or a url used for icon/image-registry (e.g. 'kvstore://image123')
284
- */
285
-
286
- }, {
287
- key: "isResourceURL",
288
- value: function isResourceURL(url) {
289
- if (!url || url.indexOf('://') < 0) {
290
- return false;
291
- }
292
-
293
- var _this$parseURL = this.parseURL(url),
294
- type = _this$parseURL.type;
295
-
296
- return type !== 'http' && type !== 'https';
145
+ throw new Error((0, i18n_exports._)("Provider not found"));
146
+ }
147
+ /**
148
+ * list all providers
149
+ * @return {Object} provider = { type: 'local', isDefault: true }
150
+ */
151
+ listProviders() {
152
+ return Object.keys(this.cachedProviders).map((type) => ({
153
+ type,
154
+ isDefault: type === this.defaultProvider.getType()
155
+ }));
156
+ }
157
+ /**
158
+ * check whether src is a http url or a url used for icon/image-registry (e.g. 'kvstore://image123')
159
+ */
160
+ isResourceURL(url) {
161
+ if (!url || url.indexOf("://") < 0) {
162
+ return false;
297
163
  }
298
- /**
299
- * parse provider type and id from the url
300
- * @params {String} url 'kvstore://image123'
301
- * @returns {Object} obj
302
- * @returns {String} obj.type 'kvstore'
303
- * @returns {String} obj.id 'image123'
304
- */
305
-
306
- }, {
307
- key: "parseURL",
308
- value: function parseURL(url) {
309
- if (url) {
310
- var _url$split = url.split('://'),
311
- _url$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_url$split, 2),
312
- type = _url$split2[0],
313
- id = _url$split2[1];
314
-
315
- if (type && id) {
316
- return {
317
- type: type,
318
- id: id
319
- };
320
- }
164
+ const { type } = this.parseURL(url);
165
+ return type !== "http" && type !== "https";
166
+ }
167
+ /**
168
+ * parse provider type and id from the url
169
+ * @params {String} url 'kvstore://image123'
170
+ * @returns {Object} obj
171
+ * @returns {String} obj.type 'kvstore'
172
+ * @returns {String} obj.id 'image123'
173
+ */
174
+ parseURL(url) {
175
+ if (url) {
176
+ const [type, id] = url.split("://");
177
+ if (type && id) {
178
+ return { type, id };
321
179
  }
322
-
323
- throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('Invalid url'));
324
180
  }
325
- /**
326
- * upload
327
- * @param {DataURI} dataURI
328
- * @param {Object} metaData
329
- * @param {String} providerType e.g. 'kvstore' or 'sui' or 'local'
330
- * @returns {String} id e.g. 'kvstore://image123'
331
- */
332
-
333
- }, {
334
- key: "upload",
335
- value: function () {
336
- var _upload = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.mark(function _callee(dataURI, metaData, providerType) {
337
- var provider, id;
338
- return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee$(_context) {
339
- while (1) {
340
- switch (_context.prev = _context.next) {
341
- case 0:
342
- if (!(providerType == null && this.defaultProvider == null)) {
343
- _context.next = 2;
344
- break;
345
- }
346
-
347
- throw new Error(Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_5__["_"])('No valid provider was found. Please add a provider'));
348
-
349
- case 2:
350
- provider = providerType ? this.findProvider(providerType) : this.defaultProvider;
351
- _context.next = 5;
352
- return provider.upload(dataURI, metaData);
353
-
354
- case 5:
355
- id = _context.sent;
356
- return _context.abrupt("return", "".concat(provider.getType(), "://").concat(id));
357
-
358
- case 7:
359
- case "end":
360
- return _context.stop();
361
- }
362
- }
363
- }, _callee, this);
364
- }));
365
-
366
- function upload(_x, _x2, _x3) {
367
- return _upload.apply(this, arguments);
368
- }
369
-
370
- return upload;
371
- }()
372
- /**
373
- * get object by url
374
- * @param {String} url 'kvstore://image123'
375
- * @returns {Object} obj e.g. an image object or icon
376
- */
377
-
378
- }, {
379
- key: "getByURL",
380
- value: function () {
381
- 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) {
382
- var _this$parseURL2, type, id, provider, obj;
383
-
384
- return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee2$(_context2) {
385
- while (1) {
386
- switch (_context2.prev = _context2.next) {
387
- case 0:
388
- _this$parseURL2 = this.parseURL(url), type = _this$parseURL2.type, id = _this$parseURL2.id;
389
- provider = this.findProvider(type);
390
- _context2.next = 4;
391
- return provider.getById(id);
392
-
393
- case 4:
394
- obj = _context2.sent;
395
- return _context2.abrupt("return", obj);
396
-
397
- case 6:
398
- case "end":
399
- return _context2.stop();
400
- }
401
- }
402
- }, _callee2, this);
403
- }));
404
-
405
- function getByURL(_x4) {
406
- return _getByURL.apply(this, arguments);
407
- }
408
-
409
- return getByURL;
410
- }()
411
- /**
412
- * delete object by url
413
- * @param {String} url 'kvstore://image123' || 'sui://icon123'
414
- * @returns {Object} obj e.g. an image object or icon
415
- */
416
-
417
- }, {
418
- key: "deleteByURL",
419
- value: function () {
420
- 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) {
421
- var _this$parseURL3, type, id, provider, obj;
422
-
423
- return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee3$(_context3) {
424
- while (1) {
425
- switch (_context3.prev = _context3.next) {
426
- case 0:
427
- _this$parseURL3 = this.parseURL(url), type = _this$parseURL3.type, id = _this$parseURL3.id;
428
- provider = this.findProvider(type);
429
- _context3.next = 4;
430
- return provider.deleteById(id);
431
-
432
- case 4:
433
- obj = _context3.sent;
434
- return _context3.abrupt("return", obj);
435
-
436
- case 6:
437
- case "end":
438
- return _context3.stop();
439
- }
440
- }
441
- }, _callee3, this);
442
- }));
443
-
444
- function deleteByURL(_x5) {
445
- return _deleteByURL.apply(this, arguments);
446
- }
447
-
448
- return deleteByURL;
449
- }()
450
- /**
451
- * list all object ids
452
- * @params {String} providerType e.g. 'kvstore' or 'sui'
453
- * @params {Object} options
454
- * @returns {Array} ids
455
- */
456
-
457
- }, {
458
- key: "listIds",
459
- value: function () {
460
- 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) {
461
- var options,
462
- provider,
463
- ids,
464
- _args4 = arguments;
465
- return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default.a.wrap(function _callee4$(_context4) {
466
- while (1) {
467
- switch (_context4.prev = _context4.next) {
468
- case 0:
469
- options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {
470
- offset: 0,
471
- count: 100
472
- };
473
- provider = this.findProvider(providerType);
474
- _context4.next = 4;
475
- return provider.listIds(options);
476
-
477
- case 4:
478
- ids = _context4.sent;
479
- return _context4.abrupt("return", ids);
480
-
481
- case 6:
482
- case "end":
483
- return _context4.stop();
484
- }
485
- }
486
- }, _callee4, this);
487
- }));
488
-
489
- function listIds(_x6) {
490
- return _listIds.apply(this, arguments);
181
+ throw new Error((0, i18n_exports._)("Invalid url"));
182
+ }
183
+ /**
184
+ * upload
185
+ * @param {DataURI} dataURI
186
+ * @param {Object} metaData
187
+ * @param {String} providerType e.g. 'kvstore' or 'sui' or 'local'
188
+ * @returns {String} id e.g. 'kvstore://image123'
189
+ */
190
+ upload(dataURI, metaData, providerType) {
191
+ return __async(this, null, function* () {
192
+ if (providerType == null && this.defaultProvider == null) {
193
+ throw new Error((0, i18n_exports._)("No valid provider was found. Please add a provider"));
491
194
  }
492
-
493
- return listIds;
494
- }()
495
- }], [{
496
- key: "create",
497
- value: function create() {
498
- return new BaseRegistry();
499
- }
500
- }]);
501
-
502
- return BaseRegistry;
503
- }();
504
-
505
- /* harmony default export */ __webpack_exports__["default"] = (BaseRegistry);
506
-
507
- /***/ })
508
- /******/ ]);
509
- //# sourceMappingURL=BaseRegistry.js.map
195
+ const provider = providerType ? this.findProvider(providerType) : this.defaultProvider;
196
+ const id = yield provider.upload(dataURI, metaData);
197
+ return `${provider.getType()}://${id}`;
198
+ });
199
+ }
200
+ /**
201
+ * get object by url
202
+ * @param {String} url 'kvstore://image123'
203
+ * @returns {Object} obj e.g. an image object or icon
204
+ */
205
+ getByURL(url) {
206
+ return __async(this, null, function* () {
207
+ const { type, id } = this.parseURL(url);
208
+ const provider = this.findProvider(type);
209
+ const obj = yield provider.getById(id);
210
+ return obj;
211
+ });
212
+ }
213
+ /**
214
+ * delete object by url
215
+ * @param {String} url 'kvstore://image123' || 'sui://icon123'
216
+ * @returns {Object} obj e.g. an image object or icon
217
+ */
218
+ deleteByURL(url) {
219
+ return __async(this, null, function* () {
220
+ const { type, id } = this.parseURL(url);
221
+ const provider = this.findProvider(type);
222
+ const obj = yield provider.deleteById(id);
223
+ return obj;
224
+ });
225
+ }
226
+ /**
227
+ * list all object ids
228
+ * @params {String} providerType e.g. 'kvstore' or 'sui'
229
+ * @params {Object} options
230
+ * @returns {Array} ids
231
+ */
232
+ listIds(_0) {
233
+ return __async(this, arguments, function* (providerType, options = { offset: 0, count: 100 }) {
234
+ const provider = this.findProvider(providerType);
235
+ const ids = yield provider.listIds(options);
236
+ return ids;
237
+ });
238
+ }
239
+ };
240
+ var BaseRegistry_default = BaseRegistry;
241
+ //# sourceMappingURL=BaseRegistry.js.map