@splitsoftware/splitio-commons 1.13.1 → 1.13.2-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 +4 -0
- package/CONTRIBUTORS-GUIDE.md +1 -1
- package/README.md +5 -3
- package/cjs/evaluator/combiners/ifelseif.js +1 -1
- package/cjs/sdkClient/sdkClient.js +6 -1
- package/cjs/services/splitApi.js +1 -1
- package/cjs/storages/KeyBuilder.js +2 -2
- package/cjs/utils/labels/index.js +2 -1
- package/esm/evaluator/combiners/ifelseif.js +1 -1
- package/esm/sdkClient/sdkClient.js +6 -1
- package/esm/services/splitApi.js +1 -1
- package/esm/storages/KeyBuilder.js +2 -2
- package/esm/utils/labels/index.js +1 -0
- package/package.json +2 -2
- package/src/evaluator/combiners/ifelseif.ts +1 -1
- package/src/evaluator/matchers/matcherTypes.ts +1 -1
- package/src/sdkClient/sdkClient.ts +8 -1
- package/src/services/splitApi.ts +1 -1
- package/src/storages/KeyBuilder.ts +2 -2
- package/src/utils/labels/index.ts +1 -0
- package/types/storages/KeyBuilder.d.ts +1 -1
- package/types/utils/labels/index.d.ts +1 -0
package/CHANGES.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
1.14.0 (April XX, 2024)
|
|
2
|
+
- Updated impression label to 'unsupported matcher type' when the matcher type is not supported by the SDK.
|
|
3
|
+
- Updated Split API client to use the version query param for the `splitChanges` endpoint.
|
|
4
|
+
|
|
1
5
|
1.13.1 (January 10, 2024)
|
|
2
6
|
- Updated client `destroy` method to release SDK key immediately and avoid unexpected warning logs when a factory is created with the same SDK key after the previous one was destroyed.
|
|
3
7
|
|
package/CONTRIBUTORS-GUIDE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Contributing to the Split
|
|
1
|
+
# Contributing to the Split JavaScript SDK Commons
|
|
2
2
|
|
|
3
3
|
Split SDK is an open source project and we welcome feedback and contribution. The information below describes how to build the project with your changes, run the tests, and send the Pull Request(PR).
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Split
|
|
1
|
+
# Split JavaScript SDK common components
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-commons) [](https://github.com/splitio/javascript-commons/actions/workflows/ci.yml)
|
|
4
4
|
|
|
@@ -27,13 +27,15 @@ Split has built and maintains SDKs for:
|
|
|
27
27
|
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
|
|
28
28
|
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
|
|
29
29
|
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
|
|
30
|
+
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
|
|
30
31
|
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
|
|
31
32
|
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
|
|
32
33
|
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
|
|
33
|
-
*
|
|
34
|
-
*
|
|
34
|
+
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
|
|
35
|
+
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
|
|
35
36
|
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
|
|
36
37
|
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
|
|
38
|
+
* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
|
|
37
39
|
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
|
|
38
40
|
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
|
|
39
41
|
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
|
|
@@ -12,7 +12,7 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
12
12
|
log.error(constants_2.ERROR_ENGINE_COMBINER_IFELSEIF);
|
|
13
13
|
return {
|
|
14
14
|
treatment: constants_1.CONTROL,
|
|
15
|
-
label: LabelsConstants.
|
|
15
|
+
label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function computeTreatment(predicateResults) {
|
|
@@ -31,6 +31,8 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
31
31
|
function __flush() {
|
|
32
32
|
return syncManager ? syncManager.flush() : Promise.resolve();
|
|
33
33
|
}
|
|
34
|
+
// Same promise if `destroy` is called multiple times
|
|
35
|
+
var destroyPromise;
|
|
34
36
|
return (0, objectAssign_1.objectAssign)(
|
|
35
37
|
// Proto-linkage of the readiness Event Emitter
|
|
36
38
|
Object.create(sdkReadinessManager.sdkStatus),
|
|
@@ -43,6 +45,8 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
43
45
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
|
44
46
|
},
|
|
45
47
|
destroy: function () {
|
|
48
|
+
if (destroyPromise)
|
|
49
|
+
return destroyPromise;
|
|
46
50
|
// Mark the SDK as destroyed immediately
|
|
47
51
|
sdkReadinessManager.readinessManager.destroy();
|
|
48
52
|
// For main client, release the SDK Key and record stat before flushing data
|
|
@@ -52,7 +56,7 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
52
56
|
}
|
|
53
57
|
// Stop background jobs
|
|
54
58
|
syncManager && syncManager.stop();
|
|
55
|
-
|
|
59
|
+
destroyPromise = __flush().then(function () {
|
|
56
60
|
// Cleanup event listeners
|
|
57
61
|
signalListener && signalListener.stop();
|
|
58
62
|
// @TODO stop only if last client is destroyed
|
|
@@ -61,6 +65,7 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
61
65
|
// Cleanup storage
|
|
62
66
|
return storage.destroy();
|
|
63
67
|
});
|
|
68
|
+
return destroyPromise;
|
|
64
69
|
}
|
|
65
70
|
});
|
|
66
71
|
}
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -41,7 +41,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
41
41
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
|
|
42
42
|
},
|
|
43
43
|
fetchSplitChanges: function (since, noCache, till) {
|
|
44
|
-
var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
44
|
+
var url = urls.sdk + "/splitChanges?v=1.0&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
45
45
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
|
|
46
46
|
.catch(function (err) {
|
|
47
47
|
if (err.statusCode === 414)
|
|
@@ -66,10 +66,10 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
66
66
|
}());
|
|
67
67
|
exports.KeyBuilder = KeyBuilder;
|
|
68
68
|
/**
|
|
69
|
-
* Generates a murmur32 hash based on the authorization key
|
|
69
|
+
* Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
|
|
70
70
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
71
71
|
*/
|
|
72
72
|
function getStorageHash(settings) {
|
|
73
|
-
return (0, murmur3_1.hash)(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString).toString(16);
|
|
73
|
+
return (0, murmur3_1.hash)(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::1.0").toString(16);
|
|
74
74
|
}
|
|
75
75
|
exports.getStorageHash = getStorageHash;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NOT_IN_SPLIT = exports.SPLIT_ARCHIVED = exports.EXCEPTION = exports.SDK_NOT_READY = exports.SPLIT_NOT_FOUND = exports.NO_CONDITION_MATCH = exports.SPLIT_KILLED = void 0;
|
|
3
|
+
exports.UNSUPPORTED_MATCHER_TYPE = exports.NOT_IN_SPLIT = exports.SPLIT_ARCHIVED = exports.EXCEPTION = exports.SDK_NOT_READY = exports.SPLIT_NOT_FOUND = exports.NO_CONDITION_MATCH = exports.SPLIT_KILLED = void 0;
|
|
4
4
|
exports.SPLIT_KILLED = 'killed';
|
|
5
5
|
exports.NO_CONDITION_MATCH = 'default rule';
|
|
6
6
|
exports.SPLIT_NOT_FOUND = 'definition not found';
|
|
@@ -8,3 +8,4 @@ exports.SDK_NOT_READY = 'not ready';
|
|
|
8
8
|
exports.EXCEPTION = 'exception';
|
|
9
9
|
exports.SPLIT_ARCHIVED = 'archived';
|
|
10
10
|
exports.NOT_IN_SPLIT = 'not in split';
|
|
11
|
+
exports.UNSUPPORTED_MATCHER_TYPE = 'unsupported matcher type';
|
|
@@ -8,7 +8,7 @@ export function ifElseIfCombinerContext(log, predicates) {
|
|
|
8
8
|
log.error(ERROR_ENGINE_COMBINER_IFELSEIF);
|
|
9
9
|
return {
|
|
10
10
|
treatment: CONTROL,
|
|
11
|
-
label: LabelsConstants.
|
|
11
|
+
label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function computeTreatment(predicateResults) {
|
|
@@ -28,6 +28,8 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
28
28
|
function __flush() {
|
|
29
29
|
return syncManager ? syncManager.flush() : Promise.resolve();
|
|
30
30
|
}
|
|
31
|
+
// Same promise if `destroy` is called multiple times
|
|
32
|
+
var destroyPromise;
|
|
31
33
|
return objectAssign(
|
|
32
34
|
// Proto-linkage of the readiness Event Emitter
|
|
33
35
|
Object.create(sdkReadinessManager.sdkStatus),
|
|
@@ -40,6 +42,8 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
40
42
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
|
41
43
|
},
|
|
42
44
|
destroy: function () {
|
|
45
|
+
if (destroyPromise)
|
|
46
|
+
return destroyPromise;
|
|
43
47
|
// Mark the SDK as destroyed immediately
|
|
44
48
|
sdkReadinessManager.readinessManager.destroy();
|
|
45
49
|
// For main client, release the SDK Key and record stat before flushing data
|
|
@@ -49,7 +53,7 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
49
53
|
}
|
|
50
54
|
// Stop background jobs
|
|
51
55
|
syncManager && syncManager.stop();
|
|
52
|
-
|
|
56
|
+
destroyPromise = __flush().then(function () {
|
|
53
57
|
// Cleanup event listeners
|
|
54
58
|
signalListener && signalListener.stop();
|
|
55
59
|
// @TODO stop only if last client is destroyed
|
|
@@ -58,6 +62,7 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
58
62
|
// Cleanup storage
|
|
59
63
|
return storage.destroy();
|
|
60
64
|
});
|
|
65
|
+
return destroyPromise;
|
|
61
66
|
}
|
|
62
67
|
});
|
|
63
68
|
}
|
package/esm/services/splitApi.js
CHANGED
|
@@ -38,7 +38,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
38
38
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
|
|
39
39
|
},
|
|
40
40
|
fetchSplitChanges: function (since, noCache, till) {
|
|
41
|
-
var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
41
|
+
var url = urls.sdk + "/splitChanges?v=1.0&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
42
42
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
|
|
43
43
|
.catch(function (err) {
|
|
44
44
|
if (err.statusCode === 414)
|
|
@@ -62,9 +62,9 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
62
62
|
}());
|
|
63
63
|
export { KeyBuilder };
|
|
64
64
|
/**
|
|
65
|
-
* Generates a murmur32 hash based on the authorization key
|
|
65
|
+
* Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
|
|
66
66
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
67
67
|
*/
|
|
68
68
|
export function getStorageHash(settings) {
|
|
69
|
-
return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString).toString(16);
|
|
69
|
+
return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::1.0").toString(16);
|
|
70
70
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "1.13.
|
|
4
|
-
"description": "Split
|
|
3
|
+
"version": "1.13.2-rc.0",
|
|
4
|
+
"description": "Split JavaScript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "types",
|
|
@@ -35,6 +35,9 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
|
|
|
35
35
|
return syncManager ? syncManager.flush() : Promise.resolve();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Same promise if `destroy` is called multiple times
|
|
39
|
+
let destroyPromise: Promise<void> | undefined;
|
|
40
|
+
|
|
38
41
|
return objectAssign(
|
|
39
42
|
// Proto-linkage of the readiness Event Emitter
|
|
40
43
|
Object.create(sdkReadinessManager.sdkStatus) as IStatusInterface,
|
|
@@ -53,6 +56,8 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
|
|
|
53
56
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
|
54
57
|
},
|
|
55
58
|
destroy() {
|
|
59
|
+
if (destroyPromise) return destroyPromise;
|
|
60
|
+
|
|
56
61
|
// Mark the SDK as destroyed immediately
|
|
57
62
|
sdkReadinessManager.readinessManager.destroy();
|
|
58
63
|
|
|
@@ -65,7 +70,7 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
|
|
|
65
70
|
// Stop background jobs
|
|
66
71
|
syncManager && syncManager.stop();
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
destroyPromise = __flush().then(() => {
|
|
69
74
|
// Cleanup event listeners
|
|
70
75
|
signalListener && signalListener.stop();
|
|
71
76
|
|
|
@@ -75,6 +80,8 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
|
|
|
75
80
|
// Cleanup storage
|
|
76
81
|
return storage.destroy();
|
|
77
82
|
});
|
|
83
|
+
|
|
84
|
+
return destroyPromise;
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
);
|
package/src/services/splitApi.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function splitApiFactory(
|
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
fetchSplitChanges(since: number, noCache?: boolean, till?: number) {
|
|
57
|
-
const url = `${urls.sdk}/splitChanges?since=${since}${till ? '&till=' + till : ''}${filterQueryString || ''}`;
|
|
57
|
+
const url = `${urls.sdk}/splitChanges?v=1.0&since=${since}${till ? '&till=' + till : ''}${filterQueryString || ''}`;
|
|
58
58
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
|
|
59
59
|
.catch((err) => {
|
|
60
60
|
if (err.statusCode === 414) settings.log.error(ERROR_TOO_MANY_SETS);
|
|
@@ -81,9 +81,9 @@ export class KeyBuilder {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Generates a murmur32 hash based on the authorization key
|
|
84
|
+
* Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
|
|
85
85
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
86
86
|
*/
|
|
87
87
|
export function getStorageHash(settings: ISettings) {
|
|
88
|
-
return hash(`${settings.core.authorizationKey}::${settings.sync.__splitFiltersValidation.queryString}`).toString(16);
|
|
88
|
+
return hash(`${settings.core.authorizationKey}::${settings.sync.__splitFiltersValidation.queryString}::1.0`).toString(16);
|
|
89
89
|
}
|
|
@@ -16,7 +16,7 @@ export declare class KeyBuilder {
|
|
|
16
16
|
buildHashKey(): string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Generates a murmur32 hash based on the authorization key
|
|
19
|
+
* Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
|
|
20
20
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
21
21
|
*/
|
|
22
22
|
export declare function getStorageHash(settings: ISettings): string;
|
|
@@ -5,3 +5,4 @@ export declare const SDK_NOT_READY = "not ready";
|
|
|
5
5
|
export declare const EXCEPTION = "exception";
|
|
6
6
|
export declare const SPLIT_ARCHIVED = "archived";
|
|
7
7
|
export declare const NOT_IN_SPLIT = "not in split";
|
|
8
|
+
export declare const UNSUPPORTED_MATCHER_TYPE = "unsupported matcher type";
|