@splitsoftware/splitio 10.17.3-rc.2 → 10.17.3-rc.3

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 (58) hide show
  1. package/es/factory/browser.js +41 -33
  2. package/es/factory/node.js +41 -36
  3. package/es/index.js +16 -1
  4. package/es/platform/EventEmitter.js +300 -326
  5. package/es/platform/browser.js +4 -4
  6. package/es/platform/getEventSource/browser.js +2 -2
  7. package/es/platform/getEventSource/node.js +13 -12
  8. package/es/platform/getFetch/browser.js +2 -2
  9. package/es/platform/getFetch/node.js +13 -13
  10. package/es/platform/node.js +5 -5
  11. package/es/platform/request/options/node.js +6 -21
  12. package/es/settings/browser.js +9 -9
  13. package/es/settings/defaults/browser.js +13 -13
  14. package/es/settings/defaults/node.js +22 -22
  15. package/es/settings/defaults/version.js +1 -1
  16. package/es/settings/integrations/browser.js +3 -3
  17. package/es/settings/node.js +9 -12
  18. package/es/settings/storage/browser.js +31 -59
  19. package/es/settings/storage/node.js +62 -91
  20. package/es/umd.js +3 -3
  21. package/lib/factory/browser.js +61 -70
  22. package/lib/factory/node.js +59 -69
  23. package/lib/index.js +16 -4
  24. package/lib/platform/EventEmitter.js +303 -330
  25. package/lib/platform/browser.js +10 -18
  26. package/lib/platform/getEventSource/browser.js +5 -6
  27. package/lib/platform/getEventSource/node.js +18 -19
  28. package/lib/platform/getFetch/browser.js +7 -10
  29. package/lib/platform/getFetch/node.js +17 -18
  30. package/lib/platform/node.js +13 -23
  31. package/lib/platform/request/options/node.js +12 -31
  32. package/lib/settings/browser.js +18 -26
  33. package/lib/settings/defaults/browser.js +15 -19
  34. package/lib/settings/defaults/node.js +24 -28
  35. package/lib/settings/defaults/version.js +2 -4
  36. package/lib/settings/integrations/browser.js +7 -12
  37. package/lib/settings/node.js +17 -29
  38. package/lib/settings/storage/browser.js +36 -68
  39. package/lib/settings/storage/node.js +66 -97
  40. package/lib/umd.js +3 -8
  41. package/package.json +23 -28
  42. package/src/factory/browser.js +10 -1
  43. package/src/factory/node.js +10 -1
  44. package/src/index.js +16 -0
  45. package/src/platform/request/options/node.js +0 -15
  46. package/src/settings/.DS_Store +0 -0
  47. package/src/settings/browser.js +2 -0
  48. package/src/settings/defaults/version.js +1 -1
  49. package/src/settings/integrations/browser.js +2 -2
  50. package/src/settings/node.js +2 -3
  51. package/src/settings/storage/browser.js +0 -16
  52. package/src/settings/storage/node.js +0 -15
  53. package/es/settings/integrations/node.js +0 -5
  54. package/es/settings/runtime/node.js +0 -35
  55. package/lib/settings/integrations/node.js +0 -12
  56. package/lib/settings/runtime/node.js +0 -45
  57. package/src/settings/integrations/node.js +0 -5
  58. package/src/settings/runtime/node.js +0 -37
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.SignalListener = exports.platform = void 0;
5
-
6
- var _EventEmitter = require("./EventEmitter");
7
-
8
- var _browser = require("../platform/getFetch/browser");
9
-
10
- var _browser2 = require("../platform/getEventSource/browser");
11
-
12
- var _browser3 = require("@splitsoftware/splitio-commons/cjs/listeners/browser");
13
-
14
- var platform = {
15
- getFetch: _browser.getFetch,
16
- getEventSource: _browser2.getEventSource,
17
- EventEmitter: _EventEmitter.EventEmitter
4
+ var EventEmitter_1 = require("./EventEmitter");
5
+ var browser_1 = require("../platform/getFetch/browser");
6
+ var browser_2 = require("../platform/getEventSource/browser");
7
+ var browser_3 = require("@splitsoftware/splitio-commons/cjs/listeners/browser");
8
+ exports.platform = {
9
+ getFetch: browser_1.getFetch,
10
+ getEventSource: browser_2.getEventSource,
11
+ EventEmitter: EventEmitter_1.EventEmitter
18
12
  };
19
- exports.platform = platform;
20
- var SignalListener = _browser3.BrowserSignalListener;
21
- exports.SignalListener = SignalListener;
13
+ exports.SignalListener = browser_3.BrowserSignalListener;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.getEventSource = getEventSource;
5
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEventSource = void 0;
6
4
  function getEventSource() {
7
- return typeof EventSource === 'function' ? EventSource : undefined;
8
- }
5
+ return typeof EventSource === 'function' ? EventSource : undefined;
6
+ }
7
+ exports.getEventSource = getEventSource;
@@ -1,26 +1,25 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.__setEventSource = __setEventSource;
5
- exports.__restore = __restore;
6
- exports.getEventSource = getEventSource;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEventSource = exports.__restore = exports.__setEventSource = void 0;
7
4
  var __isCustom = false;
8
- var __eventSource = undefined; // This function is only exposed for testing purposes.
9
-
5
+ var __eventSource = undefined;
6
+ // This function is only exposed for testing purposes.
10
7
  function __setEventSource(eventSource) {
11
- __eventSource = eventSource;
12
- __isCustom = true;
8
+ __eventSource = eventSource;
9
+ __isCustom = true;
13
10
  }
14
-
11
+ exports.__setEventSource = __setEventSource;
15
12
  function __restore() {
16
- __isCustom = false;
13
+ __isCustom = false;
17
14
  }
18
-
15
+ exports.__restore = __restore;
19
16
  function getEventSource() {
20
- // returns EventSource at `eventsource` package. If not available, return global EventSource or undefined
21
- try {
22
- return __isCustom ? __eventSource : require('eventsource');
23
- } catch (error) {
24
- return typeof EventSource === 'function' ? EventSource : undefined;
25
- }
26
- }
17
+ // returns EventSource at `eventsource` package. If not available, return global EventSource or undefined
18
+ try {
19
+ return __isCustom ? __eventSource : require('eventsource');
20
+ }
21
+ catch (error) {
22
+ return typeof EventSource === 'function' ? EventSource : undefined;
23
+ }
24
+ }
25
+ exports.getEventSource = getEventSource;
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.getFetch = getFetch;
7
-
8
- var _unfetch = _interopRequireDefault(require("unfetch"));
9
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFetch = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var unfetch_1 = (0, tslib_1.__importDefault)(require("unfetch"));
10
6
  function getFetch() {
11
- return typeof fetch === 'function' ? fetch : _unfetch.default;
12
- }
7
+ return typeof fetch === 'function' ? fetch : unfetch_1.default;
8
+ }
9
+ exports.getFetch = getFetch;
@@ -1,24 +1,23 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.__setFetch = __setFetch;
5
- exports.getFetch = getFetch;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFetch = exports.__setFetch = void 0;
6
4
  var nodeFetch;
7
-
8
5
  try {
9
- nodeFetch = require('node-fetch'); // Handle node-fetch issue https://github.com/node-fetch/node-fetch/issues/1037
10
-
11
- if (typeof nodeFetch !== 'function') nodeFetch = nodeFetch.default;
12
- } catch (error) {
13
- // Try to access global fetch if `node-fetch` package couldn't be imported (e.g., not in a Node environment)
14
- nodeFetch = typeof fetch === 'function' ? fetch : undefined;
15
- } // This function is only exposed for testing purposes.
16
-
17
-
6
+ nodeFetch = require('node-fetch');
7
+ // Handle node-fetch issue https://github.com/node-fetch/node-fetch/issues/1037
8
+ if (typeof nodeFetch !== 'function')
9
+ nodeFetch = nodeFetch.default;
10
+ }
11
+ catch (error) {
12
+ // Try to access global fetch if `node-fetch` package couldn't be imported (e.g., not in a Node environment)
13
+ nodeFetch = typeof fetch === 'function' ? fetch : undefined;
14
+ }
15
+ // This function is only exposed for testing purposes.
18
16
  function __setFetch(fetch) {
19
- nodeFetch = fetch;
17
+ nodeFetch = fetch;
20
18
  }
21
-
19
+ exports.__setFetch = __setFetch;
22
20
  function getFetch() {
23
- return nodeFetch;
24
- }
21
+ return nodeFetch;
22
+ }
23
+ exports.getFetch = getFetch;
@@ -1,26 +1,16 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.SignalListener = exports.platform = void 0;
7
-
8
- var _events = _interopRequireDefault(require("events"));
9
-
10
- var _node = require("../platform/getFetch/node");
11
-
12
- var _node2 = require("../platform/getEventSource/node");
13
-
14
- var _node3 = require("../platform/request/options/node");
15
-
16
- var _node4 = require("@splitsoftware/splitio-commons/cjs/listeners/node");
17
-
18
- var platform = {
19
- getOptions: _node3.getOptions,
20
- getFetch: _node.getFetch,
21
- getEventSource: _node2.getEventSource,
22
- EventEmitter: _events.default
4
+ var tslib_1 = require("tslib");
5
+ var events_1 = (0, tslib_1.__importDefault)(require("events"));
6
+ var node_1 = require("../platform/getFetch/node");
7
+ var node_2 = require("../platform/getEventSource/node");
8
+ var node_3 = require("../platform/request/options/node");
9
+ var node_4 = require("@splitsoftware/splitio-commons/cjs/listeners/node");
10
+ exports.platform = {
11
+ getOptions: node_3.getOptions,
12
+ getFetch: node_1.getFetch,
13
+ getEventSource: node_2.getEventSource,
14
+ EventEmitter: events_1.default
23
15
  };
24
- exports.platform = platform;
25
- var SignalListener = _node4.NodeSignalListener;
26
- exports.SignalListener = SignalListener;
16
+ exports.SignalListener = node_4.NodeSignalListener;
@@ -1,37 +1,18 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.getOptions = getOptions;
7
-
8
- var _https = _interopRequireDefault(require("https"));
9
-
10
- /**
11
- Copyright 2022 Split Software
12
-
13
- Licensed under the Apache License, Version 2.0 (the "License");
14
- you may not use this file except in compliance with the License.
15
- You may obtain a copy of the License at
16
-
17
- http://www.apache.org/licenses/LICENSE-2.0
18
-
19
- Unless required by applicable law or agreed to in writing, software
20
- distributed under the License is distributed on an "AS IS" BASIS,
21
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- See the License for the specific language governing permissions and
23
- limitations under the License.
24
- **/
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOptions = void 0;
4
+ var tslib_1 = require("tslib");
25
5
  // @TODO
26
6
  // 1- handle multiple protocols automatically
27
7
  // 2- destroy it once the sdk is destroyed
28
- var agent = new _https.default.Agent({
29
- keepAlive: true,
30
- keepAliveMsecs: 1500
8
+ var https_1 = (0, tslib_1.__importDefault)(require("https"));
9
+ var agent = new https_1.default.Agent({
10
+ keepAlive: true,
11
+ keepAliveMsecs: 1500
31
12
  });
32
-
33
13
  function getOptions() {
34
- return {
35
- agent: agent
36
- };
37
- }
14
+ return {
15
+ agent: agent
16
+ };
17
+ }
18
+ exports.getOptions = getOptions;
@@ -1,30 +1,22 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.settingsFactory = settingsFactory;
5
-
6
- var _settingsValidation = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
7
-
8
- var _browser = require("./defaults/browser");
9
-
10
- var _browser2 = require("./storage/browser");
11
-
12
- var _browser3 = require("./integrations/browser");
13
-
14
- var _builtinLogger = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
15
-
16
- var _LocalhostFromObject = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
17
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.settingsFactory = void 0;
4
+ var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
5
+ var browser_1 = require("./defaults/browser");
6
+ var browser_2 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime/browser");
7
+ var browser_3 = require("./storage/browser");
8
+ var browser_4 = require("./integrations/browser");
9
+ var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
10
+ var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
18
11
  var params = {
19
- defaults: _browser.defaults,
20
- storage: _browser2.validateStorage,
21
- integrations: _browser3.validateIntegrations,
22
- logger: _builtinLogger.validateLogger,
23
- localhost: function localhost() {
24
- return (0, _LocalhostFromObject.LocalhostFromObject)();
25
- }
12
+ defaults: browser_1.defaults,
13
+ runtime: browser_2.validateRuntime,
14
+ storage: browser_3.validateStorage,
15
+ integrations: browser_4.validateIntegrations,
16
+ logger: builtinLogger_1.validateLogger,
17
+ localhost: function () { return (0, LocalhostFromObject_1.LocalhostFromObject)(); },
26
18
  };
27
-
28
19
  function settingsFactory(config) {
29
- return (0, _settingsValidation.settingsValidation)(config, params);
30
- }
20
+ return (0, settingsValidation_1.settingsValidation)(config, params);
21
+ }
22
+ exports.settingsFactory = settingsFactory;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.defaults = void 0;
5
-
6
- var _version = require("./version");
7
-
8
- var defaults = {
9
- startup: {
10
- // Stress the request time used while starting up the SDK.
11
- requestTimeoutBeforeReady: 5,
12
- // How many quick retries we will do while starting up the SDK.
13
- retriesOnFailureBeforeReady: 1,
14
- // Maximum amount of time used before notifies me a timeout.
15
- readyTimeout: 10,
16
- // Amount of time we will wait before the first push of events.
17
- eventsFirstPushWindow: 10
18
- },
19
- // Instance version.
20
- version: "javascript-" + _version.packageVersion
4
+ var version_1 = require("./version");
5
+ exports.defaults = {
6
+ startup: {
7
+ // Stress the request time used while starting up the SDK.
8
+ requestTimeoutBeforeReady: 5,
9
+ // How many quick retries we will do while starting up the SDK.
10
+ retriesOnFailureBeforeReady: 1,
11
+ // Maximum amount of time used before notifies me a timeout.
12
+ readyTimeout: 10,
13
+ // Amount of time we will wait before the first push of events.
14
+ eventsFirstPushWindow: 10
15
+ },
16
+ // Instance version.
17
+ version: "javascript-" + version_1.packageVersion,
21
18
  };
22
- exports.defaults = defaults;
@@ -1,31 +1,27 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.defaults = void 0;
5
-
6
- var _version = require("./version");
7
-
8
- var defaults = {
9
- core: {
10
- // Default is true.
11
- IPAddressesEnabled: true
12
- },
13
- startup: {
14
- // Stress the request time used while starting up the SDK.
15
- requestTimeoutBeforeReady: 15,
16
- // How many quick retries we will do while starting up the SDK.
17
- retriesOnFailureBeforeReady: 1,
18
- // Maximum amount of time used before notifies me a timeout.
19
- readyTimeout: 15,
20
- // Don't wait a specific time for first flush on Node, no page load here.
21
- eventsFirstPushWindow: 0
22
- },
23
- scheduler: {
24
- featuresRefreshRate: 5,
25
- impressionsRefreshRate: 300
26
- },
27
- features: '.split',
28
- // Instance version.
29
- version: "nodejs-" + _version.packageVersion
4
+ var version_1 = require("./version");
5
+ exports.defaults = {
6
+ core: {
7
+ // Default is true.
8
+ IPAddressesEnabled: true
9
+ },
10
+ startup: {
11
+ // Stress the request time used while starting up the SDK.
12
+ requestTimeoutBeforeReady: 15,
13
+ // How many quick retries we will do while starting up the SDK.
14
+ retriesOnFailureBeforeReady: 1,
15
+ // Maximum amount of time used before notifies me a timeout.
16
+ readyTimeout: 15,
17
+ // Don't wait a specific time for first flush on Node, no page load here.
18
+ eventsFirstPushWindow: 0
19
+ },
20
+ scheduler: {
21
+ featuresRefreshRate: 5,
22
+ impressionsRefreshRate: 300
23
+ },
24
+ features: '.split',
25
+ // Instance version.
26
+ version: "nodejs-" + version_1.packageVersion,
30
27
  };
31
- exports.defaults = defaults;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.packageVersion = void 0;
5
- var packageVersion = '10.17.3-rc.2';
6
- exports.packageVersion = packageVersion;
4
+ exports.packageVersion = '10.17.3-rc.3';
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.validateIntegrations = void 0;
5
-
6
- var _browser = require("@splitsoftware/splitio-commons/cjs/utils/constants/browser");
7
-
8
- var _configurable = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/integrations/configurable");
9
-
10
- var validateIntegrations = function validateIntegrations(settings) {
11
- return (0, _configurable.validateConfigurableIntegrations)(settings, [_browser.GOOGLE_ANALYTICS_TO_SPLIT, _browser.SPLIT_TO_GOOGLE_ANALYTICS]);
12
- };
13
-
14
- exports.validateIntegrations = validateIntegrations;
4
+ var browser_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants/browser");
5
+ var configurable_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/integrations/configurable");
6
+ function validateIntegrations(settings) {
7
+ return (0, configurable_1.validateConfigurableIntegrations)(settings, [browser_1.GOOGLE_ANALYTICS_TO_SPLIT, browser_1.SPLIT_TO_GOOGLE_ANALYTICS]);
8
+ }
9
+ exports.validateIntegrations = validateIntegrations;
@@ -1,33 +1,21 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.settingsFactory = settingsFactory;
5
-
6
- var _settingsValidation = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
7
-
8
- var _node = require("./defaults/node");
9
-
10
- var _node2 = require("./runtime/node");
11
-
12
- var _node3 = require("./storage/node");
13
-
14
- var _node4 = require("./integrations/node");
15
-
16
- var _builtinLogger = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
17
-
18
- var _LocalhostFromFile = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromFile");
19
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.settingsFactory = void 0;
4
+ var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
5
+ var node_1 = require("./defaults/node");
6
+ var node_2 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime/node");
7
+ var node_3 = require("./storage/node");
8
+ var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
9
+ var LocalhostFromFile_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromFile");
20
10
  var params = {
21
- defaults: _node.defaults,
22
- runtime: _node2.validateRuntime,
23
- storage: _node3.validateStorage,
24
- integrations: _node4.validateIntegrations,
25
- logger: _builtinLogger.validateLogger,
26
- localhost: function localhost() {
27
- return (0, _LocalhostFromFile.LocalhostFromFile)();
28
- }
11
+ defaults: node_1.defaults,
12
+ runtime: node_2.validateRuntime,
13
+ storage: node_3.validateStorage,
14
+ logger: builtinLogger_1.validateLogger,
15
+ localhost: function () { return (0, LocalhostFromFile_1.LocalhostFromFile)(); },
16
+ // For now, Node SDK ignores settings.integrations, so no integration validator is passed
29
17
  };
30
-
31
18
  function settingsFactory(config) {
32
- return (0, _settingsValidation.settingsValidation)(config, params);
33
- }
19
+ return (0, settingsValidation_1.settingsValidation)(config, params);
20
+ }
21
+ exports.settingsFactory = settingsFactory;
@@ -1,71 +1,39 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.validateStorage = validateStorage;
5
-
6
- var _isLocalStorageAvailable = require("@splitsoftware/splitio-commons/cjs/utils/env/isLocalStorageAvailable");
7
-
8
- var _constants = require("@splitsoftware/splitio-commons/cjs/utils/constants");
9
-
10
- /**
11
- Copyright 2022 Split Software
12
-
13
- Licensed under the Apache License, Version 2.0 (the "License");
14
- you may not use this file except in compliance with the License.
15
- You may obtain a copy of the License at
16
-
17
- http://www.apache.org/licenses/LICENSE-2.0
18
-
19
- Unless required by applicable law or agreed to in writing, software
20
- distributed under the License is distributed on an "AS IS" BASIS,
21
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- See the License for the specific language governing permissions and
23
- limitations under the License.
24
- **/
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateStorage = void 0;
4
+ var isLocalStorageAvailable_1 = require("@splitsoftware/splitio-commons/cjs/utils/env/isLocalStorageAvailable");
5
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
25
6
  var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
26
-
27
7
  function validateStorage(settings) {
28
- var log = settings.log,
29
- mode = settings.mode,
30
- _settings$storage = settings.storage;
31
- _settings$storage = _settings$storage === void 0 ? {
32
- type: _constants.STORAGE_MEMORY
33
- } : _settings$storage;
34
- var type = _settings$storage.type,
35
- _settings$storage$opt = _settings$storage.options,
36
- options = _settings$storage$opt === void 0 ? {} : _settings$storage$opt,
37
- prefix = _settings$storage.prefix;
38
-
39
- var __originalType;
40
-
41
- if (prefix) {
42
- prefix += '.SPLITIO';
43
- } else {
44
- prefix = 'SPLITIO';
45
- }
46
-
47
- var fallbackToMemory = function fallbackToMemory() {
48
- __originalType = type;
49
- type = _constants.STORAGE_MEMORY;
50
- }; // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
51
- // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
52
-
53
-
54
- if (mode === _constants.LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
55
- fallbackToMemory();
56
- } // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
57
- // it's not available, fallback into MEMORY
58
-
59
-
60
- if (type !== _constants.STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE || type === STORAGE_LOCALSTORAGE && !(0, _isLocalStorageAvailable.isLocalStorageAvailable)()) {
61
- fallbackToMemory();
62
- log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
63
- }
64
-
65
- return {
66
- type: type,
67
- options: options,
68
- prefix: prefix,
69
- __originalType: __originalType
70
- };
71
- }
8
+ var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: constants_1.STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
9
+ var __originalType;
10
+ if (prefix) {
11
+ prefix += '.SPLITIO';
12
+ }
13
+ else {
14
+ prefix = 'SPLITIO';
15
+ }
16
+ var fallbackToMemory = function () {
17
+ __originalType = type;
18
+ type = constants_1.STORAGE_MEMORY;
19
+ };
20
+ // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
21
+ // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
22
+ if (mode === constants_1.LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
23
+ fallbackToMemory();
24
+ }
25
+ // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
26
+ // it's not available, fallback into MEMORY
27
+ if (type !== constants_1.STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
28
+ type === STORAGE_LOCALSTORAGE && !(0, isLocalStorageAvailable_1.isLocalStorageAvailable)()) {
29
+ fallbackToMemory();
30
+ log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
31
+ }
32
+ return {
33
+ type: type,
34
+ options: options,
35
+ prefix: prefix,
36
+ __originalType: __originalType
37
+ };
38
+ }
39
+ exports.validateStorage = validateStorage;