@splitsoftware/splitio-commons 1.15.1-rc.2 → 1.15.1-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/CHANGES.txt CHANGED
@@ -1,9 +1,9 @@
1
- 1.16.0 (June XX, 2024)
2
- - Added the `getOptions` method to the `IPlatform` interface to allow the SDK to pass request options to the `fetch` method and `EventSource` constructor when fetching data from the Split servers. The method is optional and, if provided, it is called twice: first for the `fetch` options and then for the `EventSource` options.
3
-
4
- 1.15.1 (May 28, 2024)
1
+ 1.16.0 (June 13, 2024)
2
+ - Added the `getOptions` method to the `IPlatform` interface to allow the SDK to pass request options to the `fetch` function and `EventSource` constructor when fetching data from the Split servers. The method is optional and, if provided, it is called twice: first for the `fetch` options and then for the `EventSource` options.
3
+ Useful for advanced use cases like configuring a proxy or validating certificates in NodeJS.
5
4
  - Updated the Redis storage to lazily import the `ioredis` dependency when the storage is created. This prevents errors when the SDK is imported or bundled in a .mjs file, as `ioredis` is a CommonJS module.
6
5
  - Bugfixing - Restored some input validation error logs that were removed in version 1.12.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
6
+ - Bugfixing - Fixed localhost mode for client-side SDKs to emit SDK_UPDATE when mocked feature flags are updated in the `features` property of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).
7
7
 
8
8
  1.15.0 (May 13, 2024)
9
9
  - Added an optional settings validation parameter to let overwrite the default flag spec version, used by the JS Synchronizer.
@@ -19,7 +19,7 @@ function splitsParserFromSettingsFactory() {
19
19
  var names = Object.keys(currentData);
20
20
  // Different amount of items
21
21
  if (names.length !== Object.keys(previousMock).length) {
22
- previousMock = currentData;
22
+ previousMock = (0, lang_1.merge)({}, currentData);
23
23
  return true;
24
24
  }
25
25
  return names.some(function (name) {
@@ -27,7 +27,7 @@ function splitsParserFromSettingsFactory() {
27
27
  var newTreatment = hasTreatmentChanged(previousMock[name], currentData[name]);
28
28
  var changed = newSplit || newTreatment;
29
29
  if (changed)
30
- previousMock = currentData;
30
+ previousMock = (0, lang_1.merge)({}, currentData);
31
31
  return changed;
32
32
  });
33
33
  }
@@ -94,6 +94,8 @@ function settingsValidation(config, validationParams) {
94
94
  var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
95
95
  // creates a settings object merging base, defaults and config objects.
96
96
  var withDefaults = (0, lang_1.merge)({}, exports.base, defaults, config);
97
+ // Keeps reference to the `features` property
98
+ withDefaults.features = (0, lang_1.get)(config, 'features');
97
99
  // ensure a valid logger.
98
100
  // First thing to validate, since other validators might use the logger.
99
101
  var log = logger(withDefaults); // @ts-ignore, modify readonly prop
@@ -1,4 +1,4 @@
1
- import { isObject, forOwn } from '../../../utils/lang';
1
+ import { isObject, forOwn, merge } from '../../../utils/lang';
2
2
  import { parseCondition } from './parseCondition';
3
3
  function hasTreatmentChanged(prev, curr) {
4
4
  if (typeof prev !== typeof curr)
@@ -16,7 +16,7 @@ export function splitsParserFromSettingsFactory() {
16
16
  var names = Object.keys(currentData);
17
17
  // Different amount of items
18
18
  if (names.length !== Object.keys(previousMock).length) {
19
- previousMock = currentData;
19
+ previousMock = merge({}, currentData);
20
20
  return true;
21
21
  }
22
22
  return names.some(function (name) {
@@ -24,7 +24,7 @@ export function splitsParserFromSettingsFactory() {
24
24
  var newTreatment = hasTreatmentChanged(previousMock[name], currentData[name]);
25
25
  var changed = newSplit || newTreatment;
26
26
  if (changed)
27
- previousMock = currentData;
27
+ previousMock = merge({}, currentData);
28
28
  return changed;
29
29
  });
30
30
  }
@@ -91,6 +91,8 @@ export function settingsValidation(config, validationParams) {
91
91
  var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
92
92
  // creates a settings object merging base, defaults and config objects.
93
93
  var withDefaults = merge({}, base, defaults, config);
94
+ // Keeps reference to the `features` property
95
+ withDefaults.features = get(config, 'features');
94
96
  // ensure a valid logger.
95
97
  // First thing to validate, since other validators might use the logger.
96
98
  var log = logger(withDefaults); // @ts-ignore, modify readonly prop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.15.1-rc.2",
3
+ "version": "1.15.1-rc.3",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -1,6 +1,6 @@
1
1
  import { ISplitPartial } from '../../../dtos/types';
2
2
  import { ISettings, SplitIO } from '../../../types';
3
- import { isObject, forOwn } from '../../../utils/lang';
3
+ import { isObject, forOwn, merge } from '../../../utils/lang';
4
4
  import { parseCondition } from './parseCondition';
5
5
 
6
6
  function hasTreatmentChanged(prev: string | SplitIO.TreatmentWithConfig, curr: string | SplitIO.TreatmentWithConfig) {
@@ -22,7 +22,7 @@ export function splitsParserFromSettingsFactory() {
22
22
 
23
23
  // Different amount of items
24
24
  if (names.length !== Object.keys(previousMock).length) {
25
- previousMock = currentData;
25
+ previousMock = merge({}, currentData) as SplitIO.MockedFeaturesMap;
26
26
  return true;
27
27
  }
28
28
 
@@ -31,7 +31,7 @@ export function splitsParserFromSettingsFactory() {
31
31
  const newTreatment = hasTreatmentChanged(previousMock[name], currentData[name]);
32
32
  const changed = newSplit || newTreatment;
33
33
 
34
- if (changed) previousMock = currentData;
34
+ if (changed) previousMock = merge({}, currentData) as SplitIO.MockedFeaturesMap;
35
35
 
36
36
  return changed;
37
37
  });
@@ -41,7 +41,7 @@ export function splitsParserFromSettingsFactory() {
41
41
  *
42
42
  * @param settings validated object with mocked features mapping.
43
43
  */
44
- return function splitsParserFromSettings(settings: ISettings): false | Record<string, ISplitPartial> {
44
+ return function splitsParserFromSettings(settings: Pick<ISettings, 'features'>): false | Record<string, ISplitPartial> {
45
45
  const features = settings.features as SplitIO.MockedFeaturesMap || {};
46
46
 
47
47
  if (!mockUpdated(features)) return false;
@@ -109,6 +109,8 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
109
109
 
110
110
  // creates a settings object merging base, defaults and config objects.
111
111
  const withDefaults = merge({}, base, defaults, config) as ISettings;
112
+ // Keeps reference to the `features` property
113
+ withDefaults.features = get(config, 'features');
112
114
 
113
115
  // ensure a valid logger.
114
116
  // First thing to validate, since other validators might use the logger.
@@ -1,3 +1,3 @@
1
1
  import { ISplitPartial } from '../../../dtos/types';
2
2
  import { ISettings } from '../../../types';
3
- export declare function splitsParserFromSettingsFactory(): (settings: ISettings) => false | Record<string, ISplitPartial>;
3
+ export declare function splitsParserFromSettingsFactory(): (settings: Pick<ISettings, 'features'>) => false | Record<string, ISplitPartial>;