Skip to content

Commit c53852a

Browse files
Merge pull request #89 from splitio/upgrade_js_commons
Upgrade JS commons to v2.3.0
2 parents b6f928f + 0a7cce2 commit c53852a

21 files changed

+906
-903
lines changed

CHANGES.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
0.7.1 (May XXX, 2025)
2-
- Updated some transitive dependencies for vulnerability fixes.
1+
1.0.0 (May 28, 2025)
2+
- Added support for synchronizing feature flags with rule-based segments. These segments determine membership at runtime by evaluating their configured rules against the user attributes provided to the SDK.
3+
- Added support for synchronizing feature flags with prerequisites. This allows customers to define dependency conditions between flags, which are evaluated before any allowlists or targeting rules.
4+
- Added support for synchronizing SDK impressions with properties.
5+
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance Synchronizer HTTP request Headers for Authorization Frameworks.
6+
- Updated @splitsoftware/splitio-commons package to version 2.3.0 and some transitive dependencies for vulnerability fixes and other improvements.
7+
- BREAKING CHANGES:
8+
- Dropped support for Node.js v8. The SDK now requires Node.js v14 or above.
9+
- Removed internal ponyfills for the `Map` and `Set` global objects. The SDK now requires the runtime environment to support these features natively or provide a polyfill.
310

411
0.7.0 (August 5, 2024)
512
- Added `sync.requestOptions.agent` option to allow passing a custom Node.js HTTP(S) Agent with specific configurations for the Synchronizer requests, like custom TLS settings or a network proxy (See https://help.split.io/hc/en-us/articles/4421513571469-Split-JavaScript-synchronizer-tools#proxy).
6-
- Updated some transitive dependencies for vulnerability fixes.
13+
- Updated @splitsoftware/splitio-commons package to version 1.16.0 and some transitive dependencies for vulnerability fixes.
714

815
0.6.0 (May 13, 2024)
916
- Added a new configuration option `sync.flagSpecVersion` to specify the flags spec version of feature flag definitions to be fetched and stored.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This package includes a set of JavaScript synchronization tools built based on t
88
[![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
99

1010
## Compatibility
11-
Split sync tools supports Node.js version 8 or higher. To run the tools in other JavaScript environments, the target environment must support ES6 (ECMAScript 2015) syntax, and provide built-in support or a global polyfill for Promises and Web Fetch API.
11+
Split sync tools supports Node.js version 14 or higher. To run the tools in other JavaScript environments, the target environment must support ES6 (ECMAScript 2015) syntax, and provide built-in support or a global polyfill for Promises, Web Fetch API, Map and Set.
1212

1313
## Getting started
1414
Below is a simple example that describes the execution of the JavaScript Synchronizer:

e2e/synchronizer.test.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('Synchronizer e2e tests', () => {
6666

6767
describe('Runs Synchronizer for the [FIRST] time, and', () => {
6868
beforeAll(async () => {
69-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=-1', { status: 200, body: responseMocks.splitChanges[0] });
69+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=-1&rbSince=-1', { status: 200, body: responseMocks.splitChanges[0] });
7070
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=-1', { status: 200, body: responseMocks.segmentChanges[0] });
7171
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/ENDIOS_PEREZ?since=-1', { status: 200, body: responseMocks.segmentChanges[1] });
7272
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/Lucas_Segments_Tests?since=-1', { status: 200, body: responseMocks.segmentChanges[2] });
@@ -116,6 +116,14 @@ describe('Synchronizer e2e tests', () => {
116116
expect(itemsSetB.sort()).toEqual(['TEST_DOC', 'TEST_MATIAS']);
117117
expect(itemsInexistentSet).toEqual([]);
118118
});
119+
120+
test('saves 1 rule-based segment', async () => {
121+
const ruleBasedSegments = await _redisWrapper.getKeysByPrefix(`${REDIS_PREFIX}.rbsegment.*`);
122+
expect(ruleBasedSegments).toHaveLength(1);
123+
124+
expect(await _redisWrapper.get(`${REDIS_PREFIX}.rbsegments.till`)).toBe('100');
125+
});
126+
119127
});
120128

121129
describe('Runs SDK Consumer with DEBUG impressions mode, and', () => {
@@ -144,7 +152,7 @@ describe('Synchronizer e2e tests', () => {
144152

145153
describe('Runs Synchronizer a [SECOND] time and', () => {
146154
beforeAll(async () => {
147-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=1619720346271', { status: 200, body: responseMocks.splitChanges[2] });
155+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=1619720346271&rbSince=100', { status: 200, body: responseMocks.splitChanges[2] });
148156
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
149157
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/Lucas_Segments_Tests?since=1617053238061', { status: 200, body: responseMocks.segmentChanges[6] });
150158

@@ -224,7 +232,7 @@ describe('Synchronizer e2e tests', () => {
224232
});
225233

226234
test('Run Synchronizer and check that data was popped from Redis and sent to Split BE', async () => {
227-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=1619720346272', { status: 200, body: responseMocks.splitChanges[3] });
235+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=1619720346272&rbSince=100', { status: 200, body: responseMocks.splitChanges[3] });
228236
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
229237
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/Lucas_Segments_Tests?since=1617053238061', { status: 200, body: responseMocks.segmentChanges[6] });
230238

@@ -272,7 +280,7 @@ describe('Synchronizer e2e tests', () => {
272280
});
273281

274282
test('Run Synchronizer and check that data was popped from Redis and sent to Split BE', async () => {
275-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=1619720346272', { status: 200, body: responseMocks.splitChanges[3] });
283+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=1619720346272&rbSince=100', { status: 200, body: responseMocks.splitChanges[3] });
276284
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
277285
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/Lucas_Segments_Tests?since=1617053238061', { status: 200, body: responseMocks.segmentChanges[6] });
278286

@@ -347,7 +355,7 @@ describe('Synchronizer e2e tests - OPTIMIZED impressions mode & Flag Sets filter
347355

348356
describe('Synchronizer runs the first time', () => {
349357
beforeAll(async () => {
350-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=-1&sets=set_b', { status: 200, body: responseMocks.splitChanges[0] });
358+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=-1&rbSince=-1&sets=set_b', { status: 200, body: responseMocks.splitChanges[0] });
351359
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=-1', { status: 200, body: responseMocks.segmentChanges[0] });
352360
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
353361

@@ -402,7 +410,7 @@ describe('Synchronizer e2e tests - OPTIMIZED impressions mode & Flag Sets filter
402410

403411
describe('Synchronizer runs a second time, and', () => {
404412
beforeAll(async () => {
405-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=1619720346271&sets=set_b', { status: 200, body: responseMocks.splitChanges[2] });
413+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=1619720346271&rbSince=100&sets=set_b', { status: 200, body: responseMocks.splitChanges[2] });
406414
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
407415

408416
await _synchronizer.execute();
@@ -460,7 +468,7 @@ describe('Synchronizer e2e tests - OPTIMIZED impressions mode & Flag Sets filter
460468
},
461469
});
462470

463-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=1619720346272&sets=set_b', { status: 500 });
471+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=1619720346272&rbSince=100&sets=set_b', { status: 500 });
464472
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });
465473

466474
expect(await synchronizer.execute()).toBe(false);
@@ -477,7 +485,7 @@ describe('Synchronizer e2e tests - OPTIMIZED impressions mode & Flag Sets filter
477485
},
478486
});
479487

480-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=-1&sets=set_b', { status: 500 });
488+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=-1&rbSince=-1&sets=set_b', { status: 500 });
481489

482490
expect(await synchronizer.execute()).toBe(false);
483491
expect(keys.length).toBeGreaterThan(0);
@@ -491,7 +499,7 @@ describe('Synchronizer - only Splits & Segments mode', () => {
491499
let executeImpressionsAndEventsCallSpy: jest.SpyInstance;
492500

493501
beforeAll(async () => {
494-
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.1&since=-1', { status: 200, body: responseMocks.splitChanges[0] });
502+
fetchMock.getOnce(SERVER_MOCK_URL + '/splitChanges?s=1.3&since=-1&rbSince=-1', { status: 200, body: responseMocks.splitChanges[0] });
495503
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=-1', { status: 200, body: responseMocks.segmentChanges[0] });
496504
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/Lucas_Segments_Tests?since=-1', { status: 200, body: responseMocks.segmentChanges[2] });
497505
fetchMock.getOnce(SERVER_MOCK_URL + '/segmentChanges/test_maldo?since=1589906133231', { status: 200, body: responseMocks.segmentChanges[3] });

e2e/utils/SDKConsumerMode.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const config = {
2323
* Function to run an example SDK in Consumer mode, in order to generate Events and Impressions
2424
* to be then processed by the Synchronizer.
2525
*
26-
* @param {ImpressionsMode} impressionsMode Impressions mode.
27-
* @returns {Promise}
26+
* @param impressionsMode - Impressions mode.
2827
*/
2928
export default function runSDKConsumer(impressionsMode: ImpressionsMode) {
3029
const factory = SplitFactory({

e2e/utils/redisAdapterWrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { noopLogger } from '../../src/submitters/__tests__/commonUtils';
77
* Creates a storage wrapper that uses our RedisAdapter.
88
* Operations fail until `connect` is resolved once the Redis 'ready' event is emitted.
99
*
10-
* @param {Object} redisOptions Redis options with the format expected at `settings.storage.options`.
11-
* @returns {IPluggableStorageWrapper} Storage wrapper instance.
10+
* @param redisOptions - Redis options with the format expected at `settings.storage.options`.
11+
* @returns Storage wrapper instance.
1212
*/
1313
export default function redisAdapterWrapper(redisOptions: Record<string, any>): IPluggableStorageWrapper {
1414

0 commit comments

Comments
 (0)