@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.
- package/es/factory/browser.js +41 -33
- package/es/factory/node.js +41 -36
- package/es/index.js +16 -1
- package/es/platform/EventEmitter.js +300 -326
- package/es/platform/browser.js +4 -4
- package/es/platform/getEventSource/browser.js +2 -2
- package/es/platform/getEventSource/node.js +13 -12
- package/es/platform/getFetch/browser.js +2 -2
- package/es/platform/getFetch/node.js +13 -13
- package/es/platform/node.js +5 -5
- package/es/platform/request/options/node.js +6 -21
- package/es/settings/browser.js +9 -9
- package/es/settings/defaults/browser.js +13 -13
- package/es/settings/defaults/node.js +22 -22
- package/es/settings/defaults/version.js +1 -1
- package/es/settings/integrations/browser.js +3 -3
- package/es/settings/node.js +9 -12
- package/es/settings/storage/browser.js +31 -59
- package/es/settings/storage/node.js +62 -91
- package/es/umd.js +3 -3
- package/lib/factory/browser.js +61 -70
- package/lib/factory/node.js +59 -69
- package/lib/index.js +16 -4
- package/lib/platform/EventEmitter.js +303 -330
- package/lib/platform/browser.js +10 -18
- package/lib/platform/getEventSource/browser.js +5 -6
- package/lib/platform/getEventSource/node.js +18 -19
- package/lib/platform/getFetch/browser.js +7 -10
- package/lib/platform/getFetch/node.js +17 -18
- package/lib/platform/node.js +13 -23
- package/lib/platform/request/options/node.js +12 -31
- package/lib/settings/browser.js +18 -26
- package/lib/settings/defaults/browser.js +15 -19
- package/lib/settings/defaults/node.js +24 -28
- package/lib/settings/defaults/version.js +2 -4
- package/lib/settings/integrations/browser.js +7 -12
- package/lib/settings/node.js +17 -29
- package/lib/settings/storage/browser.js +36 -68
- package/lib/settings/storage/node.js +66 -97
- package/lib/umd.js +3 -8
- package/package.json +23 -28
- package/src/factory/browser.js +10 -1
- package/src/factory/node.js +10 -1
- package/src/index.js +16 -0
- package/src/platform/request/options/node.js +0 -15
- package/src/settings/.DS_Store +0 -0
- package/src/settings/browser.js +2 -0
- package/src/settings/defaults/version.js +1 -1
- package/src/settings/integrations/browser.js +2 -2
- package/src/settings/node.js +2 -3
- package/src/settings/storage/browser.js +0 -16
- package/src/settings/storage/node.js +0 -15
- package/es/settings/integrations/node.js +0 -5
- package/es/settings/runtime/node.js +0 -35
- package/lib/settings/integrations/node.js +0 -12
- package/lib/settings/runtime/node.js +0 -45
- package/src/settings/integrations/node.js +0 -5
- package/src/settings/runtime/node.js +0 -37
package/lib/platform/browser.js
CHANGED
|
@@ -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
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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.
|
|
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.
|
|
4
|
-
exports.getEventSource = getEventSource;
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventSource = void 0;
|
|
6
4
|
function getEventSource() {
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
return typeof EventSource === 'function' ? EventSource : undefined;
|
|
6
|
+
}
|
|
7
|
+
exports.getEventSource = getEventSource;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.
|
|
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;
|
|
9
|
-
|
|
5
|
+
var __eventSource = undefined;
|
|
6
|
+
// This function is only exposed for testing purposes.
|
|
10
7
|
function __setEventSource(eventSource) {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
__eventSource = eventSource;
|
|
9
|
+
__isCustom = true;
|
|
13
10
|
}
|
|
14
|
-
|
|
11
|
+
exports.__setEventSource = __setEventSource;
|
|
15
12
|
function __restore() {
|
|
16
|
-
|
|
13
|
+
__isCustom = false;
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
exports.__restore = __restore;
|
|
19
16
|
function getEventSource() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
17
|
+
nodeFetch = fetch;
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
exports.__setFetch = __setFetch;
|
|
22
20
|
function getFetch() {
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
return nodeFetch;
|
|
22
|
+
}
|
|
23
|
+
exports.getFetch = getFetch;
|
package/lib/platform/node.js
CHANGED
|
@@ -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
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
14
|
+
return {
|
|
15
|
+
agent: agent
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.getOptions = getOptions;
|
package/lib/settings/browser.js
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return (0,
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
package/lib/settings/node.js
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
var
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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;
|