@splitsoftware/splitio-commons 3.1.1-rc.1 → 3.1.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 +1 -1
- package/cjs/evaluator/index.js +11 -6
- package/cjs/sdkClient/client.js +3 -5
- package/esm/evaluator/index.js +11 -6
- package/esm/sdkClient/client.js +3 -5
- package/package.json +1 -1
- package/src/evaluator/index.ts +11 -5
- package/src/evaluator/types.ts +1 -0
- package/src/sdkClient/client.ts +3 -4
- package/src/sync/submitters/types.ts +1 -1
- package/types/splitio.d.ts +3 -2
package/CHANGES.txt
CHANGED
package/cjs/evaluator/index.js
CHANGED
|
@@ -25,6 +25,12 @@ function treatmentsException(definitionNames) {
|
|
|
25
25
|
});
|
|
26
26
|
return evaluations;
|
|
27
27
|
}
|
|
28
|
+
function setEvaluationDataFromDefinition(evaluation, definition) {
|
|
29
|
+
return (0, objectAssign_1.objectAssign)(evaluation, {
|
|
30
|
+
definition: definition,
|
|
31
|
+
config: definition.configurations && definition.configurations[evaluation.treatment] || null
|
|
32
|
+
});
|
|
33
|
+
}
|
|
28
34
|
function evaluateFeature(log, key, definitionName, attributes, storage) {
|
|
29
35
|
var definition;
|
|
30
36
|
try {
|
|
@@ -98,8 +104,8 @@ function getEvaluation(log, key, definition, attributes, storage) {
|
|
|
98
104
|
var split = (0, Engine_1.engineParser)(log, definition, storage);
|
|
99
105
|
var evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
100
106
|
return (0, thenable_1.thenable)(evaluation) ?
|
|
101
|
-
evaluation.then(function (result) { return (
|
|
102
|
-
(
|
|
107
|
+
evaluation.then(function (result) { return setEvaluationDataFromDefinition(result, definition); }) :
|
|
108
|
+
setEvaluationDataFromDefinition(evaluation, definition);
|
|
103
109
|
}
|
|
104
110
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
105
111
|
}
|
|
@@ -131,11 +137,10 @@ function evaluateDefaultTreatment(definitionName, storage) {
|
|
|
131
137
|
exports.evaluateDefaultTreatment = evaluateDefaultTreatment;
|
|
132
138
|
function getDefaultTreatment(definition) {
|
|
133
139
|
if (definition) {
|
|
134
|
-
return {
|
|
140
|
+
return setEvaluationDataFromDefinition({
|
|
135
141
|
treatment: definition.defaultTreatment,
|
|
136
|
-
label: labels_1.NO_CONDITION_MATCH,
|
|
137
|
-
|
|
138
|
-
};
|
|
142
|
+
label: labels_1.NO_CONDITION_MATCH, // "default rule"
|
|
143
|
+
}, definition);
|
|
139
144
|
}
|
|
140
145
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
141
146
|
}
|
package/cjs/sdkClient/client.js
CHANGED
|
@@ -112,13 +112,11 @@ function clientFactory(params) {
|
|
|
112
112
|
}
|
|
113
113
|
// Internal function
|
|
114
114
|
function processEvaluation(evaluation, featureFlagName, key, withConfig, invokingMethodName, queue, options) {
|
|
115
|
-
var _a;
|
|
116
115
|
if (options === void 0) { options = {}; }
|
|
117
116
|
var matchingKey = (0, key_1.getMatching)(key);
|
|
118
117
|
var bucketingKey = (0, key_1.getBucketing)(key);
|
|
119
118
|
var definition = evaluation.definition;
|
|
120
|
-
var treatment = evaluation.treatment, label = evaluation.label;
|
|
121
|
-
var config = ((_a = definition === null || definition === void 0 ? void 0 : definition.configurations) === null || _a === void 0 ? void 0 : _a[treatment]) || null;
|
|
119
|
+
var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
|
|
122
120
|
if (treatment === constants_1.CONTROL) {
|
|
123
121
|
var fallbackTreatment = fallbackCalculator(featureFlagName, label);
|
|
124
122
|
treatment = fallbackTreatment.treatment;
|
|
@@ -135,10 +133,10 @@ function clientFactory(params) {
|
|
|
135
133
|
time: Date.now(),
|
|
136
134
|
bucketingKey: bucketingKey,
|
|
137
135
|
label: label,
|
|
138
|
-
changeNumber: definition.changeNumber,
|
|
136
|
+
changeNumber: definition === null || definition === void 0 ? void 0 : definition.changeNumber,
|
|
139
137
|
properties: stringify(options.properties)
|
|
140
138
|
},
|
|
141
|
-
disabled: options.impressionsDisabled || definition.impressionsDisabled
|
|
139
|
+
disabled: options.impressionsDisabled || (definition === null || definition === void 0 ? void 0 : definition.impressionsDisabled)
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
142
|
if (withConfig) {
|
package/esm/evaluator/index.js
CHANGED
|
@@ -22,6 +22,12 @@ function treatmentsException(definitionNames) {
|
|
|
22
22
|
});
|
|
23
23
|
return evaluations;
|
|
24
24
|
}
|
|
25
|
+
function setEvaluationDataFromDefinition(evaluation, definition) {
|
|
26
|
+
return objectAssign(evaluation, {
|
|
27
|
+
definition: definition,
|
|
28
|
+
config: definition.configurations && definition.configurations[evaluation.treatment] || null
|
|
29
|
+
});
|
|
30
|
+
}
|
|
25
31
|
export function evaluateFeature(log, key, definitionName, attributes, storage) {
|
|
26
32
|
var definition;
|
|
27
33
|
try {
|
|
@@ -92,8 +98,8 @@ function getEvaluation(log, key, definition, attributes, storage) {
|
|
|
92
98
|
var split = engineParser(log, definition, storage);
|
|
93
99
|
var evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
94
100
|
return thenable(evaluation) ?
|
|
95
|
-
evaluation.then(function (result) { return
|
|
96
|
-
|
|
101
|
+
evaluation.then(function (result) { return setEvaluationDataFromDefinition(result, definition); }) :
|
|
102
|
+
setEvaluationDataFromDefinition(evaluation, definition);
|
|
97
103
|
}
|
|
98
104
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
99
105
|
}
|
|
@@ -124,11 +130,10 @@ export function evaluateDefaultTreatment(definitionName, storage) {
|
|
|
124
130
|
}
|
|
125
131
|
function getDefaultTreatment(definition) {
|
|
126
132
|
if (definition) {
|
|
127
|
-
return {
|
|
133
|
+
return setEvaluationDataFromDefinition({
|
|
128
134
|
treatment: definition.defaultTreatment,
|
|
129
|
-
label: NO_CONDITION_MATCH,
|
|
130
|
-
|
|
131
|
-
};
|
|
135
|
+
label: NO_CONDITION_MATCH, // "default rule"
|
|
136
|
+
}, definition);
|
|
132
137
|
}
|
|
133
138
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
134
139
|
}
|
package/esm/sdkClient/client.js
CHANGED
|
@@ -108,13 +108,11 @@ export function clientFactory(params) {
|
|
|
108
108
|
}
|
|
109
109
|
// Internal function
|
|
110
110
|
function processEvaluation(evaluation, featureFlagName, key, withConfig, invokingMethodName, queue, options) {
|
|
111
|
-
var _a;
|
|
112
111
|
if (options === void 0) { options = {}; }
|
|
113
112
|
var matchingKey = getMatching(key);
|
|
114
113
|
var bucketingKey = getBucketing(key);
|
|
115
114
|
var definition = evaluation.definition;
|
|
116
|
-
var treatment = evaluation.treatment, label = evaluation.label;
|
|
117
|
-
var config = ((_a = definition === null || definition === void 0 ? void 0 : definition.configurations) === null || _a === void 0 ? void 0 : _a[treatment]) || null;
|
|
115
|
+
var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
|
|
118
116
|
if (treatment === CONTROL) {
|
|
119
117
|
var fallbackTreatment = fallbackCalculator(featureFlagName, label);
|
|
120
118
|
treatment = fallbackTreatment.treatment;
|
|
@@ -131,10 +129,10 @@ export function clientFactory(params) {
|
|
|
131
129
|
time: Date.now(),
|
|
132
130
|
bucketingKey: bucketingKey,
|
|
133
131
|
label: label,
|
|
134
|
-
changeNumber: definition.changeNumber,
|
|
132
|
+
changeNumber: definition === null || definition === void 0 ? void 0 : definition.changeNumber,
|
|
135
133
|
properties: stringify(options.properties)
|
|
136
134
|
},
|
|
137
|
-
disabled: options.impressionsDisabled || definition.impressionsDisabled
|
|
135
|
+
disabled: options.impressionsDisabled || (definition === null || definition === void 0 ? void 0 : definition.impressionsDisabled)
|
|
138
136
|
});
|
|
139
137
|
}
|
|
140
138
|
if (withConfig) {
|
package/package.json
CHANGED
package/src/evaluator/index.ts
CHANGED
|
@@ -31,6 +31,13 @@ function treatmentsException(definitionNames: string[]) {
|
|
|
31
31
|
return evaluations;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function setEvaluationDataFromDefinition(evaluation: IEvaluation, definition: IDefinition): IEvaluation {
|
|
35
|
+
return objectAssign(evaluation, {
|
|
36
|
+
definition,
|
|
37
|
+
config: definition.configurations && definition.configurations[evaluation.treatment] || null
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
export function evaluateFeature(
|
|
35
42
|
log: ILogger,
|
|
36
43
|
key: SplitIO.SplitKey,
|
|
@@ -137,8 +144,8 @@ function getEvaluation(
|
|
|
137
144
|
const evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
138
145
|
|
|
139
146
|
return thenable(evaluation) ?
|
|
140
|
-
evaluation.then(result =>
|
|
141
|
-
|
|
147
|
+
evaluation.then(result => setEvaluationDataFromDefinition(result, definition)) :
|
|
148
|
+
setEvaluationDataFromDefinition(evaluation, definition);
|
|
142
149
|
}
|
|
143
150
|
|
|
144
151
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
@@ -187,11 +194,10 @@ function getDefaultTreatment(
|
|
|
187
194
|
definition: IDefinition | null,
|
|
188
195
|
): MaybeThenable<IEvaluation> {
|
|
189
196
|
if (definition) {
|
|
190
|
-
return {
|
|
197
|
+
return setEvaluationDataFromDefinition({
|
|
191
198
|
treatment: definition.defaultTreatment,
|
|
192
199
|
label: NO_CONDITION_MATCH, // "default rule"
|
|
193
|
-
|
|
194
|
-
};
|
|
200
|
+
}, definition);
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
return EVALUATION_DEFINITION_NOT_FOUND;
|
package/src/evaluator/types.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface IEvaluation {
|
|
|
22
22
|
treatment: string,
|
|
23
23
|
label: string,
|
|
24
24
|
definition?: IDefinition
|
|
25
|
+
config?: string | null | SplitIO.JsonObject
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export type IDefinitionEvaluator = (log: ILogger, key: SplitIO.SplitKey, definitionName: string, attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync) => MaybeThenable<IEvaluation>
|
package/src/sdkClient/client.ts
CHANGED
|
@@ -142,8 +142,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
142
142
|
const bucketingKey = getBucketing(key);
|
|
143
143
|
|
|
144
144
|
const { definition } = evaluation;
|
|
145
|
-
let { treatment, label } = evaluation;
|
|
146
|
-
let config = definition?.configurations?.[treatment] || null;
|
|
145
|
+
let { treatment, label, config = null } = evaluation;
|
|
147
146
|
|
|
148
147
|
if (treatment === CONTROL) {
|
|
149
148
|
const fallbackTreatment = fallbackCalculator(featureFlagName, label);
|
|
@@ -162,10 +161,10 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
162
161
|
time: Date.now(),
|
|
163
162
|
bucketingKey,
|
|
164
163
|
label,
|
|
165
|
-
changeNumber: definition
|
|
164
|
+
changeNumber: definition?.changeNumber,
|
|
166
165
|
properties: stringify(options.properties)
|
|
167
166
|
}, // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
|
|
168
|
-
disabled: options.impressionsDisabled || definition
|
|
167
|
+
disabled: options.impressionsDisabled || definition?.impressionsDisabled
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
170
|
|
package/types/splitio.d.ts
CHANGED
|
@@ -1031,9 +1031,10 @@ declare namespace SplitIO {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
label: string;
|
|
1033
1033
|
/**
|
|
1034
|
-
* Version of the feature flag
|
|
1034
|
+
* Version of the feature flag.
|
|
1035
|
+
* Undefined if the feature flag was not found, for example, if the label is 'not ready', 'exception' or 'definition not found'.
|
|
1035
1036
|
*/
|
|
1036
|
-
changeNumber
|
|
1037
|
+
changeNumber?: number;
|
|
1037
1038
|
/**
|
|
1038
1039
|
* Previous time
|
|
1039
1040
|
*/
|