@splitsoftware/splitio 10.22.4 → 10.22.5-rc.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.
package/CHANGES.txt CHANGED
@@ -1,3 +1,9 @@
1
+ 10.22.5 (May 15, 2023)
2
+ - Updated @splitsoftware/splitio-commons package to version 1.8.2 that includes minor improvements.
3
+ - Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and IntelliSense comments.
4
+ - Updated split storage modules to optimize some operations when using Redis and pluggable storages.
5
+ - Updated some transitive dependencies for vulnerability fixes.
6
+
1
7
  10.22.4 (March 9, 2023)
2
8
  - Updated @splitsoftware/splitio-commons package to version 1.8.1 that includes minor improvements.
3
9
  - Updated some transitive dependencies for vulnerability fixes.
@@ -15,7 +21,7 @@
15
21
  10.22.0 (October 5, 2022)
16
22
  - Added a new impressions mode for the SDK called NONE, to be used in factory when there is no desire to capture impressions on an SDK factory to feed Split's analytics engine. Running NONE mode, the SDK will only capture unique keys evaluated for a particular feature flag instead of full blown impressions.
17
23
  - Updated default value of `scheduler.featuresRefreshRate` config parameter from 5 seconds to 60 seconds for NodeJS and from 30 seconds to 60 seconds for Browser.
18
- - Updated @splitsoftware/splitio-commons package to version 1.7.1, that improves the performance of split evaluations (i.e., `getTreatment(s)` method calls) when using the default storage in memory, among other improvements.
24
+ - Updated @splitsoftware/splitio-commons package to version 1.7.1, that improves the performance of feature flag evaluations (i.e., `getTreatment(s)` method calls) when using the default storage in memory, among other improvements.
19
25
 
20
26
  10.21.1 (July 25, 2022)
21
27
  - Bugfixing - Added missed type definitions `enabled` from `sync`.
@@ -84,7 +90,7 @@
84
90
  - Bugfixing - Fixed an issue returning dynamic configs when the treatment name contains a dot (".").
85
91
 
86
92
  10.16.1 (October 25, 2021)
87
- - Updated some internal modules to optimize the time efficiency of split evaluations (i.e., `getTreatment(s)` method calls).
93
+ - Updated some internal modules to optimize the time efficiency of feature flag evaluations (i.e., `getTreatment(s)` method calls).
88
94
  - Updated some dependencies for vulnerability fixes (ioredis, @babel/cli, eslint, eslint-plugin-compat).
89
95
  - Bugfixing - Fixed localhost mode with localStorage, to use a mock in memory instead of localStorage API directly but keep emitting emit SDK_READY_FROM_CACHE event.
90
96
 
@@ -171,8 +177,8 @@
171
177
  - Bugfixing - Replaced the use of `for...in` statements since it iterates over enumerable properties on the prototype chain, which might be polluted by code external to the library.
172
178
 
173
179
  10.14.0 (Jul 31, 2020)
174
- - Added `sync.splitFilters` property to SDK configuration to pass a list of filters for the splits that will be downloaded. Read more in our docs.
175
- - Added expiration policy to split cache for browsers using localStorage: cache is cleared after 10 days of the last successful update.
180
+ - Added `sync.splitFilters` property to SDK configuration to pass a list of filters for the feature flags that will be downloaded. Read more in our docs.
181
+ - Added expiration policy to SDK cache for browsers using localStorage: cache is cleared after 10 days of the last successful update.
176
182
  - Updated babel configuration to remove core-js dependency and refactored code in favor of size reduction of UMD, ESM and CommonJS builds.
177
183
  - NOTE: removed some polyfills of global objects not available in some builds of IE10.
178
184
 
@@ -205,7 +211,7 @@
205
211
  - Bugfixing - Emit SDK_UPDATE in localhost only when mock was actually updated.
206
212
 
207
213
  10.10.0 (Jan 10, 2020)
208
- - Added SDK_READY_FROM_CACHE event, which will be emitted in LocalStorage mode when the SDK finds split cache in the storage of the browser.
214
+ - Added SDK_READY_FROM_CACHE event, which will be emitted in LocalStorage mode when the SDK finds feature flag definitions in the storage of the browser.
209
215
  - Updated a dependency to fix a vulnerability (serialize-javascript).
210
216
  - Updated multiple dependencies and dev dependencies (@types/node, axios, core-js, events, sinon, tape and the babel cli, core, preset-env, register and plugin-transform-runtime)
211
217
 
@@ -220,14 +226,14 @@
220
226
  10.9.0 (Oct 24, 2019)
221
227
  - Added listener for 'unload' DOM events to push remaining impressions and events when the browser page is closed or reloaded.
222
228
  - Added setting core.IPAddressesEnabled to disable reporting IP Addresses and Machine name back to Split cloud.
223
- - Updated Redis storage to fetch multiple splits at once for getTreatments/getTreatmentsWithConfig.
229
+ - Updated Redis storage to fetch multiple feature flags at once for getTreatments/getTreatmentsWithConfig.
224
230
  - Updated most dependencies to their latest versions. Biggest change is babel (from 6 to 7), Webpack 3 to 4, Karma and ioredis.
225
231
 
226
232
  10.8.4 (Sep 24, 2019)
227
233
  - Added module "events" as optional dependency.
228
234
  - Removed dependency on "util" module.
229
235
  - Updated transport module to use a local axios instance instead of the global one, to avoid polluting the shared one.
230
- - Updated input validation log when trying to get data of a non-existent split to have level WARN instead of ERROR.
236
+ - Updated input validation log when trying to get data of a non-existent feature flag to have level WARN instead of ERROR.
231
237
 
232
238
  10.8.3 (Sep 16, 2019)
233
239
  - Updated two default values on startup configuration for Browsers:
@@ -350,7 +356,7 @@
350
356
  - Updated SDK labels.
351
357
  - Bugfixing - Shared clients (browser) were ready even if the main client was not.
352
358
  - Bugfixing - Shared clients (browser) from different SDK instances should be separate.
353
- - Bugfixing - When using API key with wrong permissions, Node was throwing a false ready event (without segments).
359
+ - Bugfixing - When using SDK key with wrong permissions, Node was throwing a false ready event (without segments).
354
360
  - Bugfixing - Localhost mode was trying to flush impressions when client.destroy was invoked.
355
361
 
356
362
  9.3.7 (Dec 22, 2017)
@@ -407,7 +413,7 @@
407
413
 
408
414
  var settings = {
409
415
  core: {
410
- authorizationKey: 'YOUR_API_KEY',
416
+ authorizationKey: 'YOUR_SDK_KEY',
411
417
  key: 'CUSTOMER_KEY' // If on the browser.
412
418
  },
413
419
  debug: true // Boolean flag for enabling logs. Default value is false.
@@ -423,7 +429,7 @@
423
429
 
424
430
  var sdk = splitio({
425
431
  core: {
426
- authorizationKey: 'YOUR_API_KEY',
432
+ authorizationKey: 'YOUR_SDK_KEY',
427
433
  key: 'CUSTOMER_KEY' // If on the browser.
428
434
  }
429
435
  });
@@ -460,13 +466,13 @@
460
466
  - Adding getTreatments method to client API. For example:
461
467
 
462
468
  ```js
463
- var treatmentsMap = client.getTreatments('CUSTOMER_KEY', ['Split_1', 'Split_2']);
469
+ var treatmentsMap = client.getTreatments('CUSTOMER_KEY', ['Feature_flag_1', 'Feature_flag_2']);
464
470
 
465
471
  /*
466
- * treatmentsMap will be an object mapping splits with treatments. For example:
472
+ * treatmentsMap will be an object mapping feature flags with treatments. For example:
467
473
  * {
468
- * Split_1: 'on',
469
- * Split_2: 'off
474
+ * Feature_flag_1: 'on',
475
+ * Feature_flag_2: 'off
470
476
  * }
471
477
  */
472
478
  ```
@@ -633,7 +639,7 @@ var treatmentsMap = client.getTreatments('CUSTOMER_KEY', ['Split_1', 'Split_2'])
633
639
 
634
640
  6.0.0 (June 24, 2016)
635
641
  - In the browser land we allow quick retries before start using the refresh
636
- rates defined for segments and splits, plus the possibility of receive an
642
+ rates defined for segments and feature flags, plus the possibility of receive an
637
643
  event when the SDK is taking to much time to startup.
638
644
 
639
645
  ```html
@@ -698,8 +704,8 @@ var treatmentsMap = client.getTreatments('CUSTOMER_KEY', ['Split_1', 'Split_2'])
698
704
  });
699
705
 
700
706
  // usage
701
- var t1 = dynamic1.getTreatment('split-name');
702
- var t2 = dynamic2.getTreatment('another-split-name');
707
+ var t1 = dynamic1.getTreatment('feature-flag-name');
708
+ var t2 = dynamic2.getTreatment('another-feature-flag-name');
703
709
 
704
710
  // stop SDK
705
711
  dynamic1.destroy();
@@ -776,7 +782,7 @@ var treatmentsMap = client.getTreatments('CUSTOMER_KEY', ['Split_1', 'Split_2'])
776
782
  ```js
777
783
  var sdk = splitio({
778
784
  core: {
779
- authorizationKey: 'c1l5vkd50gimccout3c03pntbu', // your API key
785
+ authorizationKey: 'c1l5vkd50gimccout3c03pntbu', // your SDK key
780
786
  key: '4a2c4490-ced1-11e5-9b97-d8a25e8b1578' // your customer id
781
787
  }
782
788
  });
@@ -805,7 +811,7 @@ seconds:
805
811
  ```js
806
812
  var sdk = splitio({
807
813
  core: {
808
- authorizationKey: 'c1l5vkd50gimccout3c03pntbu', // your API key
814
+ authorizationKey: 'c1l5vkd50gimccout3c03pntbu', // your SDK key
809
815
  key: '4a2c4490-ced1-11e5-9b97-d8a25e8b1578' // your customer id
810
816
  },
811
817
  scheduler: {
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # Split SDK for Javascript
1
+ # Split SDK for JavaScript
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40splitsoftware%2Fsplitio.svg)](https://badge.fury.io/js/%40splitsoftware%2Fsplitio) [![Build Status](https://github.com/splitio/javascript-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/splitio/javascript-client/actions/workflows/ci-cd.yml) [![Greenkeeper badge](https://badges.greenkeeper.io/splitio/javascript-client.svg)](https://greenkeeper.io/)
4
4
 
5
5
  ## Overview
6
- This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience.
6
+ This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.
7
7
 
8
8
  [![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
9
9
 
@@ -23,7 +23,7 @@ var SplitFactory = require('@splitsoftware/splitio').SplitFactory;
23
23
  // Instantiate the SDK
24
24
  var factory = SplitFactory({
25
25
  core: {
26
- authorizationKey: 'YOUR_SDK_API_KEY'
26
+ authorizationKey: 'YOUR_SDK_KEY'
27
27
  }
28
28
  });
29
29
 
@@ -32,7 +32,7 @@ var client = factory.client();
32
32
 
33
33
  // Set a callback to listen for the SDK_READY event, to make sure the SDK is properly loaded before asking for a treatment
34
34
  client.on(client.Event.SDK_READY, function() {
35
- var treatment = client.getTreatment('CUSTOMER_ID', 'SPLIT_NAME');
35
+ var treatment = client.getTreatment('CUSTOMER_ID', 'FEATURE_FLAG_NAME');
36
36
  if (treatment == 'on') {
37
37
  // insert code here for on treatment
38
38
  } else if (treatment == 'off') {
@@ -67,8 +67,8 @@ Split has built and maintains SDKs for:
67
67
  * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
68
68
  * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
69
69
  * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
70
- * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
71
- * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
70
+ * JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
71
+ * JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
72
72
  * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
73
73
  * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
74
74
  * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
package/es/index.js CHANGED
@@ -1,16 +1 @@
1
- /**
2
- Copyright 2022 Split Software
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- **/
16
1
  export { SplitFactory } from './factory';
@@ -1 +1 @@
1
- export var packageVersion = '10.22.4';
1
+ export var packageVersion = '10.22.5-rc.0';
@@ -3,31 +3,32 @@ import path from 'path';
3
3
  import yaml from 'js-yaml';
4
4
  import { isString, endsWith, find, forOwn, uniq, } from '@splitsoftware/splitio-commons/esm/utils/lang';
5
5
  import { parseCondition } from '@splitsoftware/splitio-commons/esm/sync/offline/splitsParser/parseCondition';
6
- var logPrefix = 'sync:offline:splits-fetcher: ';
6
+ var logPrefix = 'sync:offline:fetcher: ';
7
7
  var DEFAULT_FILENAME = '.split';
8
8
  function configFilesPath(configFilePath) {
9
9
  if (configFilePath === DEFAULT_FILENAME || !isString(configFilePath)) {
10
10
  var root = process.env.HOME;
11
+ // @TODO env var not documented in help center
11
12
  if (process.env.SPLIT_CONFIG_ROOT)
12
13
  root = process.env.SPLIT_CONFIG_ROOT;
13
14
  if (!root)
14
- throw new Error('Missing split mock configuration root.');
15
+ throw new Error('Missing root of the feature flags mock file.');
15
16
  configFilePath = path.join(root, DEFAULT_FILENAME);
16
17
  }
17
18
  // Validate the extensions
18
19
  if (!(endsWith(configFilePath, '.yaml', true) || endsWith(configFilePath, '.yml', true) || endsWith(configFilePath, '.split', true)))
19
- throw new Error("Invalid extension specified for Splits mock file. Accepted extensions are \".yml\" and \".yaml\". Your specified file is " + configFilePath);
20
+ throw new Error("Invalid extension specified for feature flags mock file. Accepted extensions are \".yml\" and \".yaml\". Your specified file is " + configFilePath);
20
21
  if (!fs.existsSync(configFilePath))
21
- throw new Error("Split configuration not found in " + configFilePath + " - Please review your Split file location.");
22
+ throw new Error("Feature flags mock file not found in " + configFilePath + " - Please review the file location.");
22
23
  return configFilePath;
23
24
  }
24
25
  // This function is not pure nor meant to be. Here we apply modifications to cover
25
26
  // for behaviour that's ensured by the BE.
26
27
  function arrangeConditions(mocksData) {
27
- // Iterate through each Split data
28
+ // Iterate through each feature flag data
28
29
  forOwn(mocksData, function (data) {
29
30
  var conditions = data.conditions;
30
- // On the manager, as the split jsons come with all treatments on the partitions prop,
31
+ // On the manager, as feature flag JSONs come with all treatments on the partitions prop,
31
32
  // we'll add all the treatments to the first condition.
32
33
  var firstRolloutCondition = find(conditions, function (cond) { return cond.conditionType === 'ROLLOUT'; });
33
34
  // Malformed mocks may have
@@ -49,9 +50,9 @@ function arrangeConditions(mocksData) {
49
50
  }
50
51
  export function splitsParserFromFileFactory() {
51
52
  var previousMock = 'NO_MOCK_LOADED';
52
- // Parse `.split` configuration file and return a map of "Split Objects"
53
- function readSplitConfigFile(log, filePath) {
54
- var SPLIT_POSITION = 0;
53
+ // Parse `.split` configuration file and return a map of feature flag objects
54
+ function readFeatureFlagConfigFile(log, filePath) {
55
+ var FEATURE_FLAG_POSITION = 0;
55
56
  var TREATMENT_POSITION = 1;
56
57
  var data;
57
58
  try {
@@ -64,7 +65,7 @@ export function splitsParserFromFileFactory() {
64
65
  if (data === previousMock)
65
66
  return false;
66
67
  previousMock = data;
67
- var splitObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
68
+ var featureFlagObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
68
69
  var tuple = line.trim();
69
70
  if (tuple === '' || tuple.charAt(0) === '#') {
70
71
  log.debug(logPrefix + ("Ignoring empty line or comment at #" + index));
@@ -75,16 +76,16 @@ export function splitsParserFromFileFactory() {
75
76
  log.debug(logPrefix + ("Ignoring line since it does not have exactly two columns #" + index));
76
77
  }
77
78
  else {
78
- var splitName = tuple[SPLIT_POSITION];
79
+ var featureFlagName = tuple[FEATURE_FLAG_POSITION];
79
80
  var condition = parseCondition({ treatment: tuple[TREATMENT_POSITION] });
80
- accum[splitName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
81
+ accum[featureFlagName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
81
82
  }
82
83
  }
83
84
  return accum;
84
85
  }, {});
85
- return splitObjects;
86
+ return featureFlagObjects;
86
87
  }
87
- // Parse `.yml` or `.yaml` configuration files and return a map of "Split Objects"
88
+ // Parse `.yml` or `.yaml` configuration files and return a map of feature flag objects
88
89
  function readYAMLConfigFile(log, filePath) {
89
90
  var data = '';
90
91
  var yamldoc = null;
@@ -100,39 +101,39 @@ export function splitsParserFromFileFactory() {
100
101
  return {};
101
102
  }
102
103
  // Each entry will be mapped to a condition, but we'll also keep the configurations map.
103
- var mocksData = (yamldoc).reduce(function (accum, splitEntry) {
104
- var splitName = Object.keys(splitEntry)[0];
105
- if (!splitName || !isString(splitEntry[splitName].treatment))
104
+ var mocksData = (yamldoc).reduce(function (accum, featureFlagEntry) {
105
+ var featureFlagName = Object.keys(featureFlagEntry)[0];
106
+ if (!featureFlagName || !isString(featureFlagEntry[featureFlagName].treatment))
106
107
  log.error(logPrefix + 'Ignoring entry on YAML since the format is incorrect.');
107
- var mockData = splitEntry[splitName];
108
- // "Template" for each split accumulated data
109
- if (!accum[splitName]) {
110
- accum[splitName] = {
108
+ var mockData = featureFlagEntry[featureFlagName];
109
+ // "Template" for each feature flag accumulated data
110
+ if (!accum[featureFlagName]) {
111
+ accum[featureFlagName] = {
111
112
  configurations: {}, conditions: [], treatments: [], trafficTypeName: 'localhost'
112
113
  };
113
114
  }
114
115
  // Assign the config if there is one on the mock
115
116
  if (mockData.config)
116
- accum[splitName].configurations[mockData.treatment] = mockData.config;
117
+ accum[featureFlagName].configurations[mockData.treatment] = mockData.config;
117
118
  // Parse the condition from the entry.
118
119
  var condition = parseCondition(mockData);
119
- accum[splitName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
120
+ accum[featureFlagName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
120
121
  // Also keep track of the treatments, will be useful for manager functionality.
121
- accum[splitName].treatments.push(mockData.treatment);
122
+ accum[featureFlagName].treatments.push(mockData.treatment);
122
123
  return accum;
123
124
  }, {});
124
125
  arrangeConditions(mocksData);
125
126
  return mocksData;
126
127
  }
127
128
  // Load the content of a configuration file into an Object
128
- return function splitsParserFromFile(_a) {
129
+ return function featureFlagsParserFromFile(_a) {
129
130
  var features = _a.features, log = _a.log;
130
131
  var filePath = configFilesPath(features);
131
132
  var mockData;
132
133
  // If we have a filePath, it means the extension is correct, choose the parser.
133
134
  if (endsWith(filePath, '.split')) {
134
135
  log.warn(logPrefix + '.split mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.');
135
- mockData = readSplitConfigFile(log, filePath);
136
+ mockData = readFeatureFlagConfigFile(log, filePath);
136
137
  }
137
138
  else {
138
139
  mockData = readYAMLConfigFile(log, filePath);
package/lib/index.js CHANGED
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- /**
3
- Copyright 2022 Split Software
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- **/
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.SplitFactory = void 0;
19
4
  var factory_1 = require("./factory");
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageVersion = void 0;
4
- exports.packageVersion = '10.22.4';
4
+ exports.packageVersion = '10.22.5-rc.0';
@@ -7,31 +7,32 @@ var path_1 = (0, tslib_1.__importDefault)(require("path"));
7
7
  var js_yaml_1 = (0, tslib_1.__importDefault)(require("js-yaml"));
8
8
  var lang_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang");
9
9
  var parseCondition_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/splitsParser/parseCondition");
10
- var logPrefix = 'sync:offline:splits-fetcher: ';
10
+ var logPrefix = 'sync:offline:fetcher: ';
11
11
  var DEFAULT_FILENAME = '.split';
12
12
  function configFilesPath(configFilePath) {
13
13
  if (configFilePath === DEFAULT_FILENAME || !(0, lang_1.isString)(configFilePath)) {
14
14
  var root = process.env.HOME;
15
+ // @TODO env var not documented in help center
15
16
  if (process.env.SPLIT_CONFIG_ROOT)
16
17
  root = process.env.SPLIT_CONFIG_ROOT;
17
18
  if (!root)
18
- throw new Error('Missing split mock configuration root.');
19
+ throw new Error('Missing root of the feature flags mock file.');
19
20
  configFilePath = path_1.default.join(root, DEFAULT_FILENAME);
20
21
  }
21
22
  // Validate the extensions
22
23
  if (!((0, lang_1.endsWith)(configFilePath, '.yaml', true) || (0, lang_1.endsWith)(configFilePath, '.yml', true) || (0, lang_1.endsWith)(configFilePath, '.split', true)))
23
- throw new Error("Invalid extension specified for Splits mock file. Accepted extensions are \".yml\" and \".yaml\". Your specified file is " + configFilePath);
24
+ throw new Error("Invalid extension specified for feature flags mock file. Accepted extensions are \".yml\" and \".yaml\". Your specified file is " + configFilePath);
24
25
  if (!fs_1.default.existsSync(configFilePath))
25
- throw new Error("Split configuration not found in " + configFilePath + " - Please review your Split file location.");
26
+ throw new Error("Feature flags mock file not found in " + configFilePath + " - Please review the file location.");
26
27
  return configFilePath;
27
28
  }
28
29
  // This function is not pure nor meant to be. Here we apply modifications to cover
29
30
  // for behaviour that's ensured by the BE.
30
31
  function arrangeConditions(mocksData) {
31
- // Iterate through each Split data
32
+ // Iterate through each feature flag data
32
33
  (0, lang_1.forOwn)(mocksData, function (data) {
33
34
  var conditions = data.conditions;
34
- // On the manager, as the split jsons come with all treatments on the partitions prop,
35
+ // On the manager, as feature flag JSONs come with all treatments on the partitions prop,
35
36
  // we'll add all the treatments to the first condition.
36
37
  var firstRolloutCondition = (0, lang_1.find)(conditions, function (cond) { return cond.conditionType === 'ROLLOUT'; });
37
38
  // Malformed mocks may have
@@ -53,9 +54,9 @@ function arrangeConditions(mocksData) {
53
54
  }
54
55
  function splitsParserFromFileFactory() {
55
56
  var previousMock = 'NO_MOCK_LOADED';
56
- // Parse `.split` configuration file and return a map of "Split Objects"
57
- function readSplitConfigFile(log, filePath) {
58
- var SPLIT_POSITION = 0;
57
+ // Parse `.split` configuration file and return a map of feature flag objects
58
+ function readFeatureFlagConfigFile(log, filePath) {
59
+ var FEATURE_FLAG_POSITION = 0;
59
60
  var TREATMENT_POSITION = 1;
60
61
  var data;
61
62
  try {
@@ -68,7 +69,7 @@ function splitsParserFromFileFactory() {
68
69
  if (data === previousMock)
69
70
  return false;
70
71
  previousMock = data;
71
- var splitObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
72
+ var featureFlagObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
72
73
  var tuple = line.trim();
73
74
  if (tuple === '' || tuple.charAt(0) === '#') {
74
75
  log.debug(logPrefix + ("Ignoring empty line or comment at #" + index));
@@ -79,16 +80,16 @@ function splitsParserFromFileFactory() {
79
80
  log.debug(logPrefix + ("Ignoring line since it does not have exactly two columns #" + index));
80
81
  }
81
82
  else {
82
- var splitName = tuple[SPLIT_POSITION];
83
+ var featureFlagName = tuple[FEATURE_FLAG_POSITION];
83
84
  var condition = (0, parseCondition_1.parseCondition)({ treatment: tuple[TREATMENT_POSITION] });
84
- accum[splitName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
85
+ accum[featureFlagName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
85
86
  }
86
87
  }
87
88
  return accum;
88
89
  }, {});
89
- return splitObjects;
90
+ return featureFlagObjects;
90
91
  }
91
- // Parse `.yml` or `.yaml` configuration files and return a map of "Split Objects"
92
+ // Parse `.yml` or `.yaml` configuration files and return a map of feature flag objects
92
93
  function readYAMLConfigFile(log, filePath) {
93
94
  var data = '';
94
95
  var yamldoc = null;
@@ -104,39 +105,39 @@ function splitsParserFromFileFactory() {
104
105
  return {};
105
106
  }
106
107
  // Each entry will be mapped to a condition, but we'll also keep the configurations map.
107
- var mocksData = (yamldoc).reduce(function (accum, splitEntry) {
108
- var splitName = Object.keys(splitEntry)[0];
109
- if (!splitName || !(0, lang_1.isString)(splitEntry[splitName].treatment))
108
+ var mocksData = (yamldoc).reduce(function (accum, featureFlagEntry) {
109
+ var featureFlagName = Object.keys(featureFlagEntry)[0];
110
+ if (!featureFlagName || !(0, lang_1.isString)(featureFlagEntry[featureFlagName].treatment))
110
111
  log.error(logPrefix + 'Ignoring entry on YAML since the format is incorrect.');
111
- var mockData = splitEntry[splitName];
112
- // "Template" for each split accumulated data
113
- if (!accum[splitName]) {
114
- accum[splitName] = {
112
+ var mockData = featureFlagEntry[featureFlagName];
113
+ // "Template" for each feature flag accumulated data
114
+ if (!accum[featureFlagName]) {
115
+ accum[featureFlagName] = {
115
116
  configurations: {}, conditions: [], treatments: [], trafficTypeName: 'localhost'
116
117
  };
117
118
  }
118
119
  // Assign the config if there is one on the mock
119
120
  if (mockData.config)
120
- accum[splitName].configurations[mockData.treatment] = mockData.config;
121
+ accum[featureFlagName].configurations[mockData.treatment] = mockData.config;
121
122
  // Parse the condition from the entry.
122
123
  var condition = (0, parseCondition_1.parseCondition)(mockData);
123
- accum[splitName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
124
+ accum[featureFlagName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
124
125
  // Also keep track of the treatments, will be useful for manager functionality.
125
- accum[splitName].treatments.push(mockData.treatment);
126
+ accum[featureFlagName].treatments.push(mockData.treatment);
126
127
  return accum;
127
128
  }, {});
128
129
  arrangeConditions(mocksData);
129
130
  return mocksData;
130
131
  }
131
132
  // Load the content of a configuration file into an Object
132
- return function splitsParserFromFile(_a) {
133
+ return function featureFlagsParserFromFile(_a) {
133
134
  var features = _a.features, log = _a.log;
134
135
  var filePath = configFilesPath(features);
135
136
  var mockData;
136
137
  // If we have a filePath, it means the extension is correct, choose the parser.
137
138
  if ((0, lang_1.endsWith)(filePath, '.split')) {
138
139
  log.warn(logPrefix + '.split mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.');
139
- mockData = readSplitConfigFile(log, filePath);
140
+ mockData = readFeatureFlagConfigFile(log, filePath);
140
141
  }
141
142
  else {
142
143
  mockData = readYAMLConfigFile(log, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.22.4",
3
+ "version": "10.22.5-rc.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -27,6 +27,11 @@
27
27
  "url": "https://github.com/NicoZelaya"
28
28
  }
29
29
  ],
30
+ "keywords": [
31
+ "splitio",
32
+ "sdk",
33
+ "javascript"
34
+ ],
30
35
  "main": "lib/index.js",
31
36
  "module": "es/index.js",
32
37
  "types": "types",
@@ -35,7 +40,7 @@
35
40
  "node": ">=6"
36
41
  },
37
42
  "dependencies": {
38
- "@splitsoftware/splitio-commons": "1.8.1",
43
+ "@splitsoftware/splitio-commons": "1.8.2-rc.2",
39
44
  "@types/google.analytics": "0.0.40",
40
45
  "@types/ioredis": "^4.28.0",
41
46
  "bloom-filters": "^3.0.0",
package/src/index.js CHANGED
@@ -1,17 +1 @@
1
- /**
2
- Copyright 2022 Split Software
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- **/
16
-
17
1
  export { SplitFactory } from './factory';