@splitsoftware/splitio-commons 1.14.1-rc.0 → 1.15.1-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 +5 -2
- package/cjs/sdkClient/client.js +0 -1
- package/cjs/sdkClient/clientInputValidation.js +25 -30
- package/cjs/utils/settingsValidation/splitFilters.js +1 -1
- package/esm/sdkClient/client.js +0 -1
- package/esm/sdkClient/clientInputValidation.js +25 -30
- package/esm/utils/settingsValidation/splitFilters.js +1 -1
- package/package.json +1 -1
- package/src/sdkClient/client.ts +0 -1
- package/src/sdkClient/clientInputValidation.ts +25 -28
- package/src/utils/settingsValidation/splitFilters.ts +2 -2
- package/types/utils/settingsValidation/splitFilters.d.ts +1 -1
package/CHANGES.txt
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
1.15.
|
|
1
|
+
1.15.1 (May 28, 2024)
|
|
2
|
+
- 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.
|
|
3
|
+
|
|
4
|
+
1.15.0 (May 13, 2024)
|
|
2
5
|
- Added an optional settings validation parameter to let overwrite the default flag spec version, used by the JS Synchronizer.
|
|
3
6
|
|
|
4
7
|
1.14.0 (May 6, 2024)
|
|
@@ -89,7 +92,7 @@
|
|
|
89
92
|
- Bugfixing - Removed js-yaml dependency to avoid resolution to an incompatible version on certain npm versions when installing third-party dependencies that also define js-yaml as transitive dependency (Related to issue https://github.com/splitio/javascript-client/issues/662).
|
|
90
93
|
|
|
91
94
|
1.5.0 (June 29, 2022)
|
|
92
|
-
- Added a new config option to control the tasks that listen or poll for updates on feature flags and segments, via the new config sync.enabled
|
|
95
|
+
- Added a new config option to control the tasks that listen or poll for updates on feature flags and segments, via the new config `sync.enabled`. Running online, Split SDK will always pull the most recent updates upon initialization, this only affects updates fetching on a running instance. Useful when a consistent session experience is a must or to save resources when updates are not being used.
|
|
93
96
|
- Updated telemetry logic to track the anonymous config for user consent flag set to declined or unknown.
|
|
94
97
|
- Updated submitters logic, to avoid duplicating the post of impressions to Split cloud when the SDK is destroyed while its periodic post of impressions is running.
|
|
95
98
|
|
package/cjs/sdkClient/client.js
CHANGED
|
@@ -165,7 +165,6 @@ function clientFactory(params) {
|
|
|
165
165
|
getTreatmentsByFlagSet: getTreatmentsByFlagSet,
|
|
166
166
|
getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
|
|
167
167
|
track: track,
|
|
168
|
-
isClientSide: false
|
|
169
168
|
};
|
|
170
169
|
}
|
|
171
170
|
exports.clientFactory = clientFactory;
|
|
@@ -17,26 +17,21 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
17
17
|
/**
|
|
18
18
|
* Avoid repeating this validations code
|
|
19
19
|
*/
|
|
20
|
-
function validateEvaluationParams(maybeKey,
|
|
21
|
-
var multi = (0, lang_1.startsWith)(methodName, constants_1.GET_TREATMENTS);
|
|
20
|
+
function validateEvaluationParams(maybeKey, maybeNameOrNames, maybeAttributes, methodName) {
|
|
22
21
|
var key = (0, inputValidation_1.validateKey)(log, maybeKey, methodName);
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
var nameOrNames = methodName.indexOf('ByFlagSet') > -1 ?
|
|
23
|
+
(0, splitFilters_1.validateFlagSets)(log, methodName, maybeNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet) :
|
|
24
|
+
(0, lang_1.startsWith)(methodName, constants_1.GET_TREATMENTS) ?
|
|
25
|
+
(0, inputValidation_1.validateSplits)(log, maybeNameOrNames, methodName) :
|
|
26
|
+
(0, inputValidation_1.validateSplit)(log, maybeNameOrNames, methodName);
|
|
28
27
|
var attributes = (0, inputValidation_1.validateAttributes)(log, maybeAttributes, methodName);
|
|
29
28
|
var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, methodName);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
(0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName, splitOrSplits);
|
|
34
|
-
var valid = isNotDestroyed && key && (splitOrSplits || flagSetOrFlagSets.length > 0) && attributes !== false;
|
|
29
|
+
(0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName, nameOrNames);
|
|
30
|
+
var valid = isNotDestroyed && key && nameOrNames && attributes !== false;
|
|
35
31
|
return {
|
|
36
32
|
valid: valid,
|
|
37
33
|
key: key,
|
|
38
|
-
|
|
39
|
-
flagSetOrFlagSets: flagSetOrFlagSets,
|
|
34
|
+
nameOrNames: nameOrNames,
|
|
40
35
|
attributes: attributes
|
|
41
36
|
};
|
|
42
37
|
}
|
|
@@ -46,7 +41,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
46
41
|
function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
47
42
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT);
|
|
48
43
|
if (params.valid) {
|
|
49
|
-
return client.getTreatment(params.key, params.
|
|
44
|
+
return client.getTreatment(params.key, params.nameOrNames, params.attributes);
|
|
50
45
|
}
|
|
51
46
|
else {
|
|
52
47
|
return wrapResult(constants_1.CONTROL);
|
|
@@ -55,7 +50,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
55
50
|
function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
56
51
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT_WITH_CONFIG);
|
|
57
52
|
if (params.valid) {
|
|
58
|
-
return client.getTreatmentWithConfig(params.key, params.
|
|
53
|
+
return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes);
|
|
59
54
|
}
|
|
60
55
|
else {
|
|
61
56
|
return wrapResult((0, objectAssign_1.objectAssign)({}, constants_1.CONTROL_WITH_CONFIG));
|
|
@@ -64,58 +59,58 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
64
59
|
function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
65
60
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS);
|
|
66
61
|
if (params.valid) {
|
|
67
|
-
return client.getTreatments(params.key, params.
|
|
62
|
+
return client.getTreatments(params.key, params.nameOrNames, params.attributes);
|
|
68
63
|
}
|
|
69
64
|
else {
|
|
70
65
|
var res_1 = {};
|
|
71
|
-
if (params.
|
|
72
|
-
params.
|
|
66
|
+
if (params.nameOrNames)
|
|
67
|
+
params.nameOrNames.forEach(function (split) { return res_1[split] = constants_1.CONTROL; });
|
|
73
68
|
return wrapResult(res_1);
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
77
72
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG);
|
|
78
73
|
if (params.valid) {
|
|
79
|
-
return client.getTreatmentsWithConfig(params.key, params.
|
|
74
|
+
return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes);
|
|
80
75
|
}
|
|
81
76
|
else {
|
|
82
77
|
var res_2 = {};
|
|
83
|
-
if (params.
|
|
84
|
-
params.
|
|
78
|
+
if (params.nameOrNames)
|
|
79
|
+
params.nameOrNames.forEach(function (split) { return res_2[split] = (0, objectAssign_1.objectAssign)({}, constants_1.CONTROL_WITH_CONFIG); });
|
|
85
80
|
return wrapResult(res_2);
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
89
|
-
var params = validateEvaluationParams(maybeKey,
|
|
84
|
+
var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SETS);
|
|
90
85
|
if (params.valid) {
|
|
91
|
-
return client.getTreatmentsByFlagSets(params.key, params.
|
|
86
|
+
return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes);
|
|
92
87
|
}
|
|
93
88
|
else {
|
|
94
89
|
return wrapResult({});
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
92
|
function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
98
|
-
var params = validateEvaluationParams(maybeKey,
|
|
93
|
+
var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
|
|
99
94
|
if (params.valid) {
|
|
100
|
-
return client.getTreatmentsWithConfigByFlagSets(params.key, params.
|
|
95
|
+
return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes);
|
|
101
96
|
}
|
|
102
97
|
else {
|
|
103
98
|
return wrapResult({});
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
107
|
-
var params = validateEvaluationParams(maybeKey,
|
|
102
|
+
var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SET);
|
|
108
103
|
if (params.valid) {
|
|
109
|
-
return client.getTreatmentsByFlagSet(params.key, params.
|
|
104
|
+
return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes);
|
|
110
105
|
}
|
|
111
106
|
else {
|
|
112
107
|
return wrapResult({});
|
|
113
108
|
}
|
|
114
109
|
}
|
|
115
110
|
function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
116
|
-
var params = validateEvaluationParams(maybeKey,
|
|
111
|
+
var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
|
|
117
112
|
if (params.valid) {
|
|
118
|
-
return client.getTreatmentsWithConfigByFlagSet(params.key, params.
|
|
113
|
+
return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes);
|
|
119
114
|
}
|
|
120
115
|
else {
|
|
121
116
|
return wrapResult({});
|
package/esm/sdkClient/client.js
CHANGED
|
@@ -14,26 +14,21 @@ export function clientInputValidationDecorator(settings, client, readinessManage
|
|
|
14
14
|
/**
|
|
15
15
|
* Avoid repeating this validations code
|
|
16
16
|
*/
|
|
17
|
-
function validateEvaluationParams(maybeKey,
|
|
18
|
-
var multi = startsWith(methodName, GET_TREATMENTS);
|
|
17
|
+
function validateEvaluationParams(maybeKey, maybeNameOrNames, maybeAttributes, methodName) {
|
|
19
18
|
var key = validateKey(log, maybeKey, methodName);
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
var nameOrNames = methodName.indexOf('ByFlagSet') > -1 ?
|
|
20
|
+
validateFlagSets(log, methodName, maybeNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet) :
|
|
21
|
+
startsWith(methodName, GET_TREATMENTS) ?
|
|
22
|
+
validateSplits(log, maybeNameOrNames, methodName) :
|
|
23
|
+
validateSplit(log, maybeNameOrNames, methodName);
|
|
25
24
|
var attributes = validateAttributes(log, maybeAttributes, methodName);
|
|
26
25
|
var isNotDestroyed = validateIfNotDestroyed(log, readinessManager, methodName);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
validateIfOperational(log, readinessManager, methodName, splitOrSplits);
|
|
31
|
-
var valid = isNotDestroyed && key && (splitOrSplits || flagSetOrFlagSets.length > 0) && attributes !== false;
|
|
26
|
+
validateIfOperational(log, readinessManager, methodName, nameOrNames);
|
|
27
|
+
var valid = isNotDestroyed && key && nameOrNames && attributes !== false;
|
|
32
28
|
return {
|
|
33
29
|
valid: valid,
|
|
34
30
|
key: key,
|
|
35
|
-
|
|
36
|
-
flagSetOrFlagSets: flagSetOrFlagSets,
|
|
31
|
+
nameOrNames: nameOrNames,
|
|
37
32
|
attributes: attributes
|
|
38
33
|
};
|
|
39
34
|
}
|
|
@@ -43,7 +38,7 @@ export function clientInputValidationDecorator(settings, client, readinessManage
|
|
|
43
38
|
function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
44
39
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT);
|
|
45
40
|
if (params.valid) {
|
|
46
|
-
return client.getTreatment(params.key, params.
|
|
41
|
+
return client.getTreatment(params.key, params.nameOrNames, params.attributes);
|
|
47
42
|
}
|
|
48
43
|
else {
|
|
49
44
|
return wrapResult(CONTROL);
|
|
@@ -52,7 +47,7 @@ export function clientInputValidationDecorator(settings, client, readinessManage
|
|
|
52
47
|
function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
53
48
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT_WITH_CONFIG);
|
|
54
49
|
if (params.valid) {
|
|
55
|
-
return client.getTreatmentWithConfig(params.key, params.
|
|
50
|
+
return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes);
|
|
56
51
|
}
|
|
57
52
|
else {
|
|
58
53
|
return wrapResult(objectAssign({}, CONTROL_WITH_CONFIG));
|
|
@@ -61,58 +56,58 @@ export function clientInputValidationDecorator(settings, client, readinessManage
|
|
|
61
56
|
function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
62
57
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS);
|
|
63
58
|
if (params.valid) {
|
|
64
|
-
return client.getTreatments(params.key, params.
|
|
59
|
+
return client.getTreatments(params.key, params.nameOrNames, params.attributes);
|
|
65
60
|
}
|
|
66
61
|
else {
|
|
67
62
|
var res_1 = {};
|
|
68
|
-
if (params.
|
|
69
|
-
params.
|
|
63
|
+
if (params.nameOrNames)
|
|
64
|
+
params.nameOrNames.forEach(function (split) { return res_1[split] = CONTROL; });
|
|
70
65
|
return wrapResult(res_1);
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
74
69
|
var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS_WITH_CONFIG);
|
|
75
70
|
if (params.valid) {
|
|
76
|
-
return client.getTreatmentsWithConfig(params.key, params.
|
|
71
|
+
return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes);
|
|
77
72
|
}
|
|
78
73
|
else {
|
|
79
74
|
var res_2 = {};
|
|
80
|
-
if (params.
|
|
81
|
-
params.
|
|
75
|
+
if (params.nameOrNames)
|
|
76
|
+
params.nameOrNames.forEach(function (split) { return res_2[split] = objectAssign({}, CONTROL_WITH_CONFIG); });
|
|
82
77
|
return wrapResult(res_2);
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
80
|
function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
86
|
-
var params = validateEvaluationParams(maybeKey,
|
|
81
|
+
var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_BY_FLAG_SETS);
|
|
87
82
|
if (params.valid) {
|
|
88
|
-
return client.getTreatmentsByFlagSets(params.key, params.
|
|
83
|
+
return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes);
|
|
89
84
|
}
|
|
90
85
|
else {
|
|
91
86
|
return wrapResult({});
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
95
|
-
var params = validateEvaluationParams(maybeKey,
|
|
90
|
+
var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
|
|
96
91
|
if (params.valid) {
|
|
97
|
-
return client.getTreatmentsWithConfigByFlagSets(params.key, params.
|
|
92
|
+
return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes);
|
|
98
93
|
}
|
|
99
94
|
else {
|
|
100
95
|
return wrapResult({});
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
104
|
-
var params = validateEvaluationParams(maybeKey,
|
|
99
|
+
var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_BY_FLAG_SET);
|
|
105
100
|
if (params.valid) {
|
|
106
|
-
return client.getTreatmentsByFlagSet(params.key, params.
|
|
101
|
+
return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes);
|
|
107
102
|
}
|
|
108
103
|
else {
|
|
109
104
|
return wrapResult({});
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
113
|
-
var params = validateEvaluationParams(maybeKey,
|
|
108
|
+
var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
|
|
114
109
|
if (params.valid) {
|
|
115
|
-
return client.getTreatmentsWithConfigByFlagSet(params.key, params.
|
|
110
|
+
return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes);
|
|
116
111
|
}
|
|
117
112
|
else {
|
|
118
113
|
return wrapResult({});
|
package/package.json
CHANGED
package/src/sdkClient/client.ts
CHANGED
|
@@ -31,29 +31,26 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
|
|
|
31
31
|
/**
|
|
32
32
|
* Avoid repeating this validations code
|
|
33
33
|
*/
|
|
34
|
-
function validateEvaluationParams(maybeKey: SplitIO.SplitKey,
|
|
35
|
-
const multi = startsWith(methodName, GET_TREATMENTS);
|
|
34
|
+
function validateEvaluationParams(maybeKey: SplitIO.SplitKey, maybeNameOrNames: string | string[], maybeAttributes: SplitIO.Attributes | undefined, methodName: string) {
|
|
36
35
|
const key = validateKey(log, maybeKey, methodName);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
|
|
37
|
+
const nameOrNames = methodName.indexOf('ByFlagSet') > -1 ?
|
|
38
|
+
validateFlagSets(log, methodName, maybeNameOrNames as string[], settings.sync.__splitFiltersValidation.groupedFilters.bySet) :
|
|
39
|
+
startsWith(methodName, GET_TREATMENTS) ?
|
|
40
|
+
validateSplits(log, maybeNameOrNames, methodName) :
|
|
41
|
+
validateSplit(log, maybeNameOrNames, methodName);
|
|
42
|
+
|
|
42
43
|
const attributes = validateAttributes(log, maybeAttributes, methodName);
|
|
43
44
|
const isNotDestroyed = validateIfNotDestroyed(log, readinessManager, methodName);
|
|
44
|
-
if (maybeFlagSetNameOrNames) {
|
|
45
|
-
flagSetOrFlagSets = validateFlagSets(log, methodName, maybeFlagSetNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet);
|
|
46
|
-
}
|
|
47
45
|
|
|
48
|
-
validateIfOperational(log, readinessManager, methodName,
|
|
46
|
+
validateIfOperational(log, readinessManager, methodName, nameOrNames);
|
|
49
47
|
|
|
50
|
-
const valid = isNotDestroyed && key &&
|
|
48
|
+
const valid = isNotDestroyed && key && nameOrNames && attributes !== false;
|
|
51
49
|
|
|
52
50
|
return {
|
|
53
51
|
valid,
|
|
54
52
|
key,
|
|
55
|
-
|
|
56
|
-
flagSetOrFlagSets,
|
|
53
|
+
nameOrNames,
|
|
57
54
|
attributes
|
|
58
55
|
};
|
|
59
56
|
}
|
|
@@ -66,7 +63,7 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
|
|
|
66
63
|
const params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT);
|
|
67
64
|
|
|
68
65
|
if (params.valid) {
|
|
69
|
-
return client.getTreatment(params.key as SplitIO.SplitKey, params.
|
|
66
|
+
return client.getTreatment(params.key as SplitIO.SplitKey, params.nameOrNames as string, params.attributes as SplitIO.Attributes | undefined);
|
|
70
67
|
} else {
|
|
71
68
|
return wrapResult(CONTROL);
|
|
72
69
|
}
|
|
@@ -76,7 +73,7 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
|
|
|
76
73
|
const params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT_WITH_CONFIG);
|
|
77
74
|
|
|
78
75
|
if (params.valid) {
|
|
79
|
-
return client.getTreatmentWithConfig(params.key as SplitIO.SplitKey, params.
|
|
76
|
+
return client.getTreatmentWithConfig(params.key as SplitIO.SplitKey, params.nameOrNames as string, params.attributes as SplitIO.Attributes | undefined);
|
|
80
77
|
} else {
|
|
81
78
|
return wrapResult(objectAssign({}, CONTROL_WITH_CONFIG));
|
|
82
79
|
}
|
|
@@ -86,10 +83,10 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
|
|
|
86
83
|
const params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS);
|
|
87
84
|
|
|
88
85
|
if (params.valid) {
|
|
89
|
-
return client.getTreatments(params.key as SplitIO.SplitKey, params.
|
|
86
|
+
return client.getTreatments(params.key as SplitIO.SplitKey, params.nameOrNames as string[], params.attributes as SplitIO.Attributes | undefined);
|
|
90
87
|
} else {
|
|
91
88
|
const res: SplitIO.Treatments = {};
|
|
92
|
-
if (params.
|
|
89
|
+
if (params.nameOrNames) (params.nameOrNames as string[]).forEach((split: string) => res[split] = CONTROL);
|
|
93
90
|
|
|
94
91
|
return wrapResult(res);
|
|
95
92
|
}
|
|
@@ -99,50 +96,50 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
|
|
|
99
96
|
const params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS_WITH_CONFIG);
|
|
100
97
|
|
|
101
98
|
if (params.valid) {
|
|
102
|
-
return client.getTreatmentsWithConfig(params.key as SplitIO.SplitKey, params.
|
|
99
|
+
return client.getTreatmentsWithConfig(params.key as SplitIO.SplitKey, params.nameOrNames as string[], params.attributes as SplitIO.Attributes | undefined);
|
|
103
100
|
} else {
|
|
104
101
|
const res: SplitIO.TreatmentsWithConfig = {};
|
|
105
|
-
if (params.
|
|
102
|
+
if (params.nameOrNames) (params.nameOrNames as string[]).forEach(split => res[split] = objectAssign({}, CONTROL_WITH_CONFIG));
|
|
106
103
|
|
|
107
104
|
return wrapResult(res);
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
|
|
111
108
|
function getTreatmentsByFlagSets(maybeKey: SplitIO.SplitKey, maybeFlagSets: string[], maybeAttributes?: SplitIO.Attributes) {
|
|
112
|
-
const params = validateEvaluationParams(maybeKey,
|
|
109
|
+
const params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_BY_FLAG_SETS);
|
|
113
110
|
|
|
114
111
|
if (params.valid) {
|
|
115
|
-
return client.getTreatmentsByFlagSets(params.key as SplitIO.SplitKey, params.
|
|
112
|
+
return client.getTreatmentsByFlagSets(params.key as SplitIO.SplitKey, params.nameOrNames as string[], params.attributes as SplitIO.Attributes | undefined);
|
|
116
113
|
} else {
|
|
117
114
|
return wrapResult({});
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
function getTreatmentsWithConfigByFlagSets(maybeKey: SplitIO.SplitKey, maybeFlagSets: string[], maybeAttributes?: SplitIO.Attributes) {
|
|
122
|
-
const params = validateEvaluationParams(maybeKey,
|
|
119
|
+
const params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
|
|
123
120
|
|
|
124
121
|
if (params.valid) {
|
|
125
|
-
return client.getTreatmentsWithConfigByFlagSets(params.key as SplitIO.SplitKey, params.
|
|
122
|
+
return client.getTreatmentsWithConfigByFlagSets(params.key as SplitIO.SplitKey, params.nameOrNames as string[], params.attributes as SplitIO.Attributes | undefined);
|
|
126
123
|
} else {
|
|
127
124
|
return wrapResult({});
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
128
|
function getTreatmentsByFlagSet(maybeKey: SplitIO.SplitKey, maybeFlagSet: string, maybeAttributes?: SplitIO.Attributes) {
|
|
132
|
-
const params = validateEvaluationParams(maybeKey,
|
|
129
|
+
const params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_BY_FLAG_SET);
|
|
133
130
|
|
|
134
131
|
if (params.valid) {
|
|
135
|
-
return client.getTreatmentsByFlagSet(params.key as SplitIO.SplitKey, params.
|
|
132
|
+
return client.getTreatmentsByFlagSet(params.key as SplitIO.SplitKey, (params.nameOrNames as string[])[0], params.attributes as SplitIO.Attributes | undefined);
|
|
136
133
|
} else {
|
|
137
134
|
return wrapResult({});
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
137
|
|
|
141
138
|
function getTreatmentsWithConfigByFlagSet(maybeKey: SplitIO.SplitKey, maybeFlagSet: string, maybeAttributes?: SplitIO.Attributes) {
|
|
142
|
-
const params = validateEvaluationParams(maybeKey,
|
|
139
|
+
const params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
|
|
143
140
|
|
|
144
141
|
if (params.valid) {
|
|
145
|
-
return client.getTreatmentsWithConfigByFlagSet(params.key as SplitIO.SplitKey, params.
|
|
142
|
+
return client.getTreatmentsWithConfigByFlagSet(params.key as SplitIO.SplitKey, (params.nameOrNames as string[])[0], params.attributes as SplitIO.Attributes | undefined);
|
|
146
143
|
} else {
|
|
147
144
|
return wrapResult({});
|
|
148
145
|
}
|
|
@@ -189,7 +189,7 @@ export function validateSplitFilters(log: ILogger, maybeSplitFilters: any, mode:
|
|
|
189
189
|
return res;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
export function validateFlagSets(log: ILogger, method: string, flagSets: string[], flagSetsInConfig: string[]): string[] {
|
|
192
|
+
export function validateFlagSets(log: ILogger, method: string, flagSets: string[], flagSetsInConfig: string[]): string[] | false {
|
|
193
193
|
const sets = validateSplits(log, flagSets, method, 'flag sets', 'flag set');
|
|
194
194
|
let toReturn = sets ? sanitizeFlagSets(log, sets, method) : [];
|
|
195
195
|
if (flagSetsInConfig.length > 0) {
|
|
@@ -202,5 +202,5 @@ export function validateFlagSets(log: ILogger, method: string, flagSets: string[
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
return toReturn;
|
|
205
|
+
return toReturn.length ? toReturn : false;
|
|
206
206
|
}
|
|
@@ -14,4 +14,4 @@ import { ILogger } from '../../logger/types';
|
|
|
14
14
|
* @throws Error if the some of the grouped list of values per filter exceeds the max allowed length
|
|
15
15
|
*/
|
|
16
16
|
export declare function validateSplitFilters(log: ILogger, maybeSplitFilters: any, mode: string): ISplitFiltersValidation;
|
|
17
|
-
export declare function validateFlagSets(log: ILogger, method: string, flagSets: string[], flagSetsInConfig: string[]): string[];
|
|
17
|
+
export declare function validateFlagSets(log: ILogger, method: string, flagSets: string[], flagSetsInConfig: string[]): string[] | false;
|