@splitsoftware/splitio-commons 3.1.0 → 3.1.1-rc.1

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.
Files changed (35) hide show
  1. package/CHANGES.txt +4 -0
  2. package/cjs/evaluator/condition/index.js +1 -1
  3. package/cjs/evaluator/index.js +26 -46
  4. package/cjs/listeners/browser.js +2 -2
  5. package/cjs/sdkClient/client.js +18 -17
  6. package/cjs/services/authProvider.js +1 -1
  7. package/cjs/storages/utils.js +1 -0
  8. package/cjs/sync/submitters/impressionsSubmitter.js +5 -4
  9. package/esm/evaluator/condition/index.js +1 -1
  10. package/esm/evaluator/index.js +26 -46
  11. package/esm/listeners/browser.js +2 -2
  12. package/esm/sdkClient/client.js +18 -17
  13. package/esm/services/authProvider.js +1 -1
  14. package/esm/storages/utils.js +1 -0
  15. package/esm/sync/submitters/impressionsSubmitter.js +5 -4
  16. package/package.json +1 -1
  17. package/src/dtos/types.ts +7 -0
  18. package/src/evaluator/Engine.ts +3 -3
  19. package/src/evaluator/condition/index.ts +2 -2
  20. package/src/evaluator/index.ts +33 -79
  21. package/src/evaluator/types.ts +3 -6
  22. package/src/listeners/browser.ts +2 -2
  23. package/src/sdkClient/client.ts +24 -25
  24. package/src/sdkFactory/types.ts +0 -4
  25. package/src/services/authProvider.ts +1 -1
  26. package/src/storages/utils.ts +1 -0
  27. package/src/sync/submitters/impressionsSubmitter.ts +6 -6
  28. package/src/sync/submitters/types.ts +2 -1
  29. package/types/splitio.d.ts +1 -171
  30. package/cjs/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +0 -70
  31. package/cjs/evaluator/fallbackConfigsCalculator/index.js +0 -25
  32. package/esm/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +0 -64
  33. package/esm/evaluator/fallbackConfigsCalculator/index.js +0 -21
  34. package/src/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.ts +0 -76
  35. package/src/evaluator/fallbackConfigsCalculator/index.ts +0 -24
package/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 3.2.0 (August 10, 2026)
2
+ - Added support for AI configs.
3
+ - Removed Configs SDK-related types and modules and moved them to the Configs SDK repository.
4
+
1
5
  3.1.0 (July 23, 2026)
2
6
  - Added support for rule-based segments in /api/v1/configs endpoint.
3
7
  - Updated polling flow to fetch new referenced segments immediately.
@@ -23,7 +23,7 @@ function conditionContext(log, matcherEvaluator, treatments, label, conditionTyp
23
23
  // Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
24
24
  if (conditionType === 'ROLLOUT' && !(0, engineUtils_1.shouldApplyRollout)(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
25
25
  return {
26
- treatment: undefined,
26
+ // treatment value is assigned later, at Engine's evaluationResult
27
27
  label: labels_1.NOT_IN_SPLIT
28
28
  };
29
29
  }
@@ -7,6 +7,7 @@ var labels_1 = require("../utils/labels");
7
7
  var constants_1 = require("../utils/constants");
8
8
  var sets_1 = require("../utils/lang/sets");
9
9
  var constants_2 = require("../logger/constants");
10
+ var objectAssign_1 = require("../utils/lang/objectAssign");
10
11
  var EVALUATION_EXCEPTION = {
11
12
  treatment: constants_1.CONTROL,
12
13
  label: labels_1.EXCEPTION,
@@ -24,7 +25,7 @@ function treatmentsException(definitionNames) {
24
25
  });
25
26
  return evaluations;
26
27
  }
27
- function evaluateFeature(log, key, definitionName, attributes, storage, options) {
28
+ function evaluateFeature(log, key, definitionName, attributes, storage) {
28
29
  var definition;
29
30
  try {
30
31
  definition = storage.definitions.get(definitionName);
@@ -33,16 +34,16 @@ function evaluateFeature(log, key, definitionName, attributes, storage, options)
33
34
  // Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
34
35
  return EVALUATION_EXCEPTION;
35
36
  }
36
- if ((0, thenable_1.thenable)(definition)) {
37
- return definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage, options); }).catch(
37
+ return (0, thenable_1.thenable)(definition) ?
38
+ definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage); })
39
+ .catch(
38
40
  // Exception on async storage. For example, when the storage is redis or
39
41
  // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
40
- function () { return EVALUATION_EXCEPTION; });
41
- }
42
- return getEvaluation(log, key, definition, attributes, storage, options);
42
+ function () { return EVALUATION_EXCEPTION; }) :
43
+ getEvaluation(log, key, definition, attributes, storage);
43
44
  }
44
45
  exports.evaluateFeature = evaluateFeature;
45
- function evaluateFeatures(log, key, definitionNames, attributes, storage, options) {
46
+ function evaluateFeatures(log, key, definitionNames, attributes, storage) {
46
47
  var definitions;
47
48
  try {
48
49
  definitions = storage.definitions.getMany(definitionNames);
@@ -52,16 +53,15 @@ function evaluateFeatures(log, key, definitionNames, attributes, storage, option
52
53
  return treatmentsException(definitionNames);
53
54
  }
54
55
  return (0, thenable_1.thenable)(definitions) ?
55
- definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage, options); })
56
- .catch(function () {
57
- // Exception on async storage. For example, when the storage is redis or
58
- // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
59
- return treatmentsException(definitionNames);
60
- }) :
61
- getEvaluations(log, key, definitionNames, definitions, attributes, storage, options);
56
+ definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage); })
57
+ .catch(
58
+ // Exception on async storage. For example, when the storage is redis or
59
+ // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
60
+ function () { return treatmentsException(definitionNames); }) :
61
+ getEvaluations(log, key, definitionNames, definitions, attributes, storage);
62
62
  }
63
63
  exports.evaluateFeatures = evaluateFeatures;
64
- function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method, options) {
64
+ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
65
65
  var storedFlagNames;
66
66
  function evaluate(featureFlagsByFlagSets) {
67
67
  var featureFlags = new Set();
@@ -75,7 +75,7 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
75
75
  }
76
76
  }
77
77
  return featureFlags.size ?
78
- evaluateFeatures(log, key, (0, sets_1.setToArray)(featureFlags), attributes, storage, options) :
78
+ evaluateFeatures(log, key, (0, sets_1.setToArray)(featureFlags), attributes, storage) :
79
79
  {};
80
80
  }
81
81
  // get features by flag sets
@@ -89,49 +89,30 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
89
89
  // evaluate related features
90
90
  return (0, thenable_1.thenable)(storedFlagNames) ?
91
91
  storedFlagNames.then(function (storedFlagNames) { return evaluate(storedFlagNames); })
92
- .catch(function () {
93
- return {};
94
- }) :
92
+ .catch(function () { return ({}); }) :
95
93
  evaluate(storedFlagNames);
96
94
  }
97
95
  exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
98
- function getEvaluation(log, key, definition, attributes, storage, options) {
96
+ function getEvaluation(log, key, definition, attributes, storage) {
99
97
  if (definition) {
100
98
  var split = (0, Engine_1.engineParser)(log, definition, storage);
101
99
  var evaluation = split.getTreatment(key, attributes, evaluateFeature);
102
- // If the storage is async and the evaluated definition uses segments or dependencies, evaluation is thenable
103
- if ((0, thenable_1.thenable)(evaluation)) {
104
- return evaluation.then(function (result) {
105
- result.changeNumber = definition.changeNumber;
106
- result.config = definition.configurations && definition.configurations[result.treatment] || null;
107
- // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
108
- result.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
109
- return result;
110
- });
111
- }
112
- else {
113
- evaluation.changeNumber = definition.changeNumber;
114
- evaluation.config = definition.configurations && definition.configurations[evaluation.treatment] || null;
115
- // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
116
- evaluation.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
117
- }
118
- return evaluation;
100
+ return (0, thenable_1.thenable)(evaluation) ?
101
+ evaluation.then(function (result) { return (0, objectAssign_1.objectAssign)(result, { definition: definition }); }) :
102
+ (0, objectAssign_1.objectAssign)(evaluation, { definition: definition });
119
103
  }
120
104
  return EVALUATION_DEFINITION_NOT_FOUND;
121
105
  }
122
- function getEvaluations(log, key, definitionNames, definitions, attributes, storage, options) {
106
+ function getEvaluations(log, key, definitionNames, definitions, attributes, storage) {
123
107
  var result = {};
124
108
  var thenables = [];
125
109
  definitionNames.forEach(function (definitionName) {
126
- var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage, options);
127
- if ((0, thenable_1.thenable)(evaluation)) {
110
+ var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage);
111
+ (0, thenable_1.thenable)(evaluation) ?
128
112
  thenables.push(evaluation.then(function (res) {
129
113
  result[definitionName] = res;
130
- }));
131
- }
132
- else {
114
+ })) :
133
115
  result[definitionName] = evaluation;
134
- }
135
116
  });
136
117
  return thenables.length > 0 ? Promise.all(thenables).then(function () { return result; }) : result;
137
118
  }
@@ -153,8 +134,7 @@ function getDefaultTreatment(definition) {
153
134
  return {
154
135
  treatment: definition.defaultTreatment,
155
136
  label: labels_1.NO_CONDITION_MATCH,
156
- config: definition.configurations && definition.configurations[definition.defaultTreatment] || null,
157
- changeNumber: definition.changeNumber
137
+ definition: definition,
158
138
  };
159
139
  }
160
140
  return EVALUATION_DEFINITION_NOT_FOUND;
@@ -14,14 +14,14 @@ var EVENT_NAME = 'for visibilitychange and pagehide events.';
14
14
  */
15
15
  var BrowserSignalListener = /** @class */ (function () {
16
16
  function BrowserSignalListener(_a) {
17
- var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi, entityType = _a.entityType;
17
+ var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi;
18
18
  this.syncManager = syncManager;
19
19
  this.settings = settings;
20
20
  this.storage = storage;
21
21
  this.serviceApi = serviceApi;
22
22
  this.flushData = this.flushData.bind(this);
23
23
  this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
24
- this.fromImpressionsCollector = impressionsSubmitter_1.fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled, entityType);
24
+ this.fromImpressionsCollector = impressionsSubmitter_1.fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
25
25
  }
26
26
  /**
27
27
  * start method.
@@ -18,10 +18,10 @@ function treatmentsNotReady(featureFlagNames) {
18
18
  });
19
19
  return evaluations;
20
20
  }
21
- function stringify(options) {
22
- if (options && options.properties) {
21
+ function stringify(properties) {
22
+ if (properties) {
23
23
  try {
24
- return JSON.stringify(options.properties);
24
+ return JSON.stringify(properties);
25
25
  }
26
26
  catch ( /* JSON.stringify should never throw with validated options, but handling just in case */_a) { /* JSON.stringify should never throw with validated options, but handling just in case */ }
27
27
  }
@@ -40,13 +40,13 @@ function clientFactory(params) {
40
40
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? constants_1.TREATMENT_WITH_CONFIG : constants_1.TREATMENT);
41
41
  var wrapUp = function (evaluationResult) {
42
42
  var queue = [];
43
- var treatment = processEvaluation(evaluationResult, featureFlagName, key, stringify(options), withConfig, methodName, queue);
43
+ var treatment = processEvaluation(evaluationResult, featureFlagName, key, withConfig, methodName, queue, options);
44
44
  impressionsTracker.track(queue, attributes);
45
45
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
46
46
  return treatment;
47
47
  };
48
48
  var evaluation = readinessManager.isReadyFromCache() ?
49
- (0, evaluator_1.evaluateFeature)(log, key, featureFlagName, attributes, storage, options) :
49
+ (0, evaluator_1.evaluateFeature)(log, key, featureFlagName, attributes, storage) :
50
50
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
51
51
  Promise.resolve(treatmentNotReady) :
52
52
  treatmentNotReady;
@@ -62,16 +62,15 @@ function clientFactory(params) {
62
62
  var wrapUp = function (evaluationResults) {
63
63
  var queue = [];
64
64
  var treatments = {};
65
- var properties = stringify(options);
66
65
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
67
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
66
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, withConfig, methodName, queue, options);
68
67
  });
69
68
  impressionsTracker.track(queue, attributes);
70
69
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
71
70
  return treatments;
72
71
  };
73
72
  var evaluations = readinessManager.isReadyFromCache() ?
74
- (0, evaluator_1.evaluateFeatures)(log, key, featureFlagNames, attributes, storage, options) :
73
+ (0, evaluator_1.evaluateFeatures)(log, key, featureFlagNames, attributes, storage) :
75
74
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
76
75
  Promise.resolve(treatmentsNotReady(featureFlagNames)) :
77
76
  treatmentsNotReady(featureFlagNames);
@@ -88,16 +87,15 @@ function clientFactory(params) {
88
87
  var wrapUp = function (evaluationResults) {
89
88
  var queue = [];
90
89
  var treatments = {};
91
- var properties = stringify(options);
92
90
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
93
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
91
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, withConfig, methodName, queue, options);
94
92
  });
95
93
  impressionsTracker.track(queue, attributes);
96
94
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
97
95
  return treatments;
98
96
  };
99
97
  var evaluations = readinessManager.isReadyFromCache() ?
100
- (0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage, methodName, options) :
98
+ (0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage, methodName) :
101
99
  isAsync ?
102
100
  Promise.resolve({}) :
103
101
  {};
@@ -113,11 +111,14 @@ function clientFactory(params) {
113
111
  return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
114
112
  }
115
113
  // Internal function
116
- function processEvaluation(evaluation, featureFlagName, key, properties, withConfig, invokingMethodName, queue) {
114
+ function processEvaluation(evaluation, featureFlagName, key, withConfig, invokingMethodName, queue, options) {
115
+ var _a;
116
+ if (options === void 0) { options = {}; }
117
117
  var matchingKey = (0, key_1.getMatching)(key);
118
118
  var bucketingKey = (0, key_1.getBucketing)(key);
119
- var changeNumber = evaluation.changeNumber, impressionsDisabled = evaluation.impressionsDisabled;
120
- var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
119
+ 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;
121
122
  if (treatment === constants_1.CONTROL) {
122
123
  var fallbackTreatment = fallbackCalculator(featureFlagName, label);
123
124
  treatment = fallbackTreatment.treatment;
@@ -134,10 +135,10 @@ function clientFactory(params) {
134
135
  time: Date.now(),
135
136
  bucketingKey: bucketingKey,
136
137
  label: label,
137
- changeNumber: changeNumber,
138
- properties: properties
138
+ changeNumber: definition.changeNumber,
139
+ properties: stringify(options.properties)
139
140
  },
140
- disabled: impressionsDisabled
141
+ disabled: options.impressionsDisabled || definition.impressionsDisabled
141
142
  });
142
143
  }
143
144
  if (withConfig) {
@@ -16,7 +16,7 @@ function isExpired(credential) {
16
16
  function authProviderFactory(settings, splitHttpClient, telemetryTracker) {
17
17
  var urls = settings.urls, log = settings.log;
18
18
  function fetchAuth() {
19
- var url = "".concat(urls.auth, "/api/v3/auth?capabilities=config");
19
+ var url = "".concat(urls.auth, "/api/v3/auth?capabilities=config,aiconfig");
20
20
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_2.TOKEN), false, true);
21
21
  }
22
22
  var authenticate = (0, AuthClient_1.authenticateFactory)(fetchAuth);
@@ -28,6 +28,7 @@ function impressionsToJSON(impressions, metadata) {
28
28
  m: impression.time,
29
29
  pt: impression.pt,
30
30
  properties: impression.properties
31
+ // @TODO set entityType
31
32
  }
32
33
  };
33
34
  return JSON.stringify(impressionWithMetadata);
@@ -7,7 +7,7 @@ var constants_1 = require("../../logger/constants");
7
7
  /**
8
8
  * Converts `impressions` data from cache into request payload.
9
9
  */
10
- function fromImpressionsCollector(sendLabels, entityType, data) {
10
+ function fromImpressionsCollector(sendLabels, data) {
11
11
  var groupedByFeature = (0, lang_1.groupBy)(data, 'feature');
12
12
  var dto = [];
13
13
  (0, lang_1.forOwn)(groupedByFeature, function (value, name) {
@@ -23,7 +23,8 @@ function fromImpressionsCollector(sendLabels, entityType, data) {
23
23
  b: entry.bucketingKey,
24
24
  pt: entry.pt,
25
25
  properties: entry.properties,
26
- et: entityType, // Definition type
26
+ // @ts-expect-error - entityType is not yet public. @TODO: add to SplitIO.ImpressionDTO type
27
+ et: entry.entityType, // Definition type
27
28
  };
28
29
  })
29
30
  });
@@ -35,9 +36,9 @@ exports.fromImpressionsCollector = fromImpressionsCollector;
35
36
  * Submitter that periodically posts impressions data
36
37
  */
37
38
  function impressionsSubmitterFactory(params) {
38
- var _a = params.settings, log = _a.log, impressionsRefreshRate = _a.scheduler.impressionsRefreshRate, labelsEnabled = _a.core.labelsEnabled, postTestImpressionsBulk = params.serviceApi.postTestImpressionsBulk, impressions = params.storage.impressions, entityType = params.entityType;
39
+ var _a = params.settings, log = _a.log, impressionsRefreshRate = _a.scheduler.impressionsRefreshRate, labelsEnabled = _a.core.labelsEnabled, postTestImpressionsBulk = params.serviceApi.postTestImpressionsBulk, impressions = params.storage.impressions;
39
40
  // retry impressions only once.
40
- var syncTask = (0, submitter_1.submitterFactory)(log, postTestImpressionsBulk, impressions, impressionsRefreshRate, fromImpressionsCollector.bind(undefined, labelsEnabled, entityType), 1);
41
+ var syncTask = (0, submitter_1.submitterFactory)(log, postTestImpressionsBulk, impressions, impressionsRefreshRate, fromImpressionsCollector.bind(undefined, labelsEnabled), 1);
41
42
  // register impressions submitter to be executed when impressions cache is full
42
43
  impressions.setOnFullQueueCb(function () {
43
44
  if (syncTask.isRunning()) {
@@ -20,7 +20,7 @@ export function conditionContext(log, matcherEvaluator, treatments, label, condi
20
20
  // Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
21
21
  if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
22
22
  return {
23
- treatment: undefined,
23
+ // treatment value is assigned later, at Engine's evaluationResult
24
24
  label: NOT_IN_SPLIT
25
25
  };
26
26
  }
@@ -4,6 +4,7 @@ import { EXCEPTION, NO_CONDITION_MATCH, DEFINITION_NOT_FOUND } from '../utils/la
4
4
  import { CONTROL } from '../utils/constants';
5
5
  import { returnSetsUnion, setToArray } from '../utils/lang/sets';
6
6
  import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
7
+ import { objectAssign } from '../utils/lang/objectAssign';
7
8
  var EVALUATION_EXCEPTION = {
8
9
  treatment: CONTROL,
9
10
  label: EXCEPTION,
@@ -21,7 +22,7 @@ function treatmentsException(definitionNames) {
21
22
  });
22
23
  return evaluations;
23
24
  }
24
- export function evaluateFeature(log, key, definitionName, attributes, storage, options) {
25
+ export function evaluateFeature(log, key, definitionName, attributes, storage) {
25
26
  var definition;
26
27
  try {
27
28
  definition = storage.definitions.get(definitionName);
@@ -30,15 +31,15 @@ export function evaluateFeature(log, key, definitionName, attributes, storage, o
30
31
  // Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
31
32
  return EVALUATION_EXCEPTION;
32
33
  }
33
- if (thenable(definition)) {
34
- return definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage, options); }).catch(
34
+ return thenable(definition) ?
35
+ definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage); })
36
+ .catch(
35
37
  // Exception on async storage. For example, when the storage is redis or
36
38
  // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
37
- function () { return EVALUATION_EXCEPTION; });
38
- }
39
- return getEvaluation(log, key, definition, attributes, storage, options);
39
+ function () { return EVALUATION_EXCEPTION; }) :
40
+ getEvaluation(log, key, definition, attributes, storage);
40
41
  }
41
- export function evaluateFeatures(log, key, definitionNames, attributes, storage, options) {
42
+ export function evaluateFeatures(log, key, definitionNames, attributes, storage) {
42
43
  var definitions;
43
44
  try {
44
45
  definitions = storage.definitions.getMany(definitionNames);
@@ -48,15 +49,14 @@ export function evaluateFeatures(log, key, definitionNames, attributes, storage,
48
49
  return treatmentsException(definitionNames);
49
50
  }
50
51
  return thenable(definitions) ?
51
- definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage, options); })
52
- .catch(function () {
53
- // Exception on async storage. For example, when the storage is redis or
54
- // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
55
- return treatmentsException(definitionNames);
56
- }) :
57
- getEvaluations(log, key, definitionNames, definitions, attributes, storage, options);
52
+ definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage); })
53
+ .catch(
54
+ // Exception on async storage. For example, when the storage is redis or
55
+ // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
56
+ function () { return treatmentsException(definitionNames); }) :
57
+ getEvaluations(log, key, definitionNames, definitions, attributes, storage);
58
58
  }
59
- export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method, options) {
59
+ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
60
60
  var storedFlagNames;
61
61
  function evaluate(featureFlagsByFlagSets) {
62
62
  var featureFlags = new Set();
@@ -70,7 +70,7 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
70
70
  }
71
71
  }
72
72
  return featureFlags.size ?
73
- evaluateFeatures(log, key, setToArray(featureFlags), attributes, storage, options) :
73
+ evaluateFeatures(log, key, setToArray(featureFlags), attributes, storage) :
74
74
  {};
75
75
  }
76
76
  // get features by flag sets
@@ -84,48 +84,29 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
84
84
  // evaluate related features
85
85
  return thenable(storedFlagNames) ?
86
86
  storedFlagNames.then(function (storedFlagNames) { return evaluate(storedFlagNames); })
87
- .catch(function () {
88
- return {};
89
- }) :
87
+ .catch(function () { return ({}); }) :
90
88
  evaluate(storedFlagNames);
91
89
  }
92
- function getEvaluation(log, key, definition, attributes, storage, options) {
90
+ function getEvaluation(log, key, definition, attributes, storage) {
93
91
  if (definition) {
94
92
  var split = engineParser(log, definition, storage);
95
93
  var evaluation = split.getTreatment(key, attributes, evaluateFeature);
96
- // If the storage is async and the evaluated definition uses segments or dependencies, evaluation is thenable
97
- if (thenable(evaluation)) {
98
- return evaluation.then(function (result) {
99
- result.changeNumber = definition.changeNumber;
100
- result.config = definition.configurations && definition.configurations[result.treatment] || null;
101
- // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
102
- result.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
103
- return result;
104
- });
105
- }
106
- else {
107
- evaluation.changeNumber = definition.changeNumber;
108
- evaluation.config = definition.configurations && definition.configurations[evaluation.treatment] || null;
109
- // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
110
- evaluation.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
111
- }
112
- return evaluation;
94
+ return thenable(evaluation) ?
95
+ evaluation.then(function (result) { return objectAssign(result, { definition: definition }); }) :
96
+ objectAssign(evaluation, { definition: definition });
113
97
  }
114
98
  return EVALUATION_DEFINITION_NOT_FOUND;
115
99
  }
116
- function getEvaluations(log, key, definitionNames, definitions, attributes, storage, options) {
100
+ function getEvaluations(log, key, definitionNames, definitions, attributes, storage) {
117
101
  var result = {};
118
102
  var thenables = [];
119
103
  definitionNames.forEach(function (definitionName) {
120
- var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage, options);
121
- if (thenable(evaluation)) {
104
+ var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage);
105
+ thenable(evaluation) ?
122
106
  thenables.push(evaluation.then(function (res) {
123
107
  result[definitionName] = res;
124
- }));
125
- }
126
- else {
108
+ })) :
127
109
  result[definitionName] = evaluation;
128
- }
129
110
  });
130
111
  return thenables.length > 0 ? Promise.all(thenables).then(function () { return result; }) : result;
131
112
  }
@@ -146,8 +127,7 @@ function getDefaultTreatment(definition) {
146
127
  return {
147
128
  treatment: definition.defaultTreatment,
148
129
  label: NO_CONDITION_MATCH,
149
- config: definition.configurations && definition.configurations[definition.defaultTreatment] || null,
150
- changeNumber: definition.changeNumber
130
+ definition: definition,
151
131
  };
152
132
  }
153
133
  return EVALUATION_DEFINITION_NOT_FOUND;
@@ -11,14 +11,14 @@ var EVENT_NAME = 'for visibilitychange and pagehide events.';
11
11
  */
12
12
  var BrowserSignalListener = /** @class */ (function () {
13
13
  function BrowserSignalListener(_a) {
14
- var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi, entityType = _a.entityType;
14
+ var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi;
15
15
  this.syncManager = syncManager;
16
16
  this.settings = settings;
17
17
  this.storage = storage;
18
18
  this.serviceApi = serviceApi;
19
19
  this.flushData = this.flushData.bind(this);
20
20
  this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
21
- this.fromImpressionsCollector = fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled, entityType);
21
+ this.fromImpressionsCollector = fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
22
22
  }
23
23
  /**
24
24
  * start method.
@@ -15,10 +15,10 @@ function treatmentsNotReady(featureFlagNames) {
15
15
  });
16
16
  return evaluations;
17
17
  }
18
- export function stringify(options) {
19
- if (options && options.properties) {
18
+ export function stringify(properties) {
19
+ if (properties) {
20
20
  try {
21
- return JSON.stringify(options.properties);
21
+ return JSON.stringify(properties);
22
22
  }
23
23
  catch ( /* JSON.stringify should never throw with validated options, but handling just in case */_a) { /* JSON.stringify should never throw with validated options, but handling just in case */ }
24
24
  }
@@ -36,13 +36,13 @@ export function clientFactory(params) {
36
36
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENT_WITH_CONFIG : TREATMENT);
37
37
  var wrapUp = function (evaluationResult) {
38
38
  var queue = [];
39
- var treatment = processEvaluation(evaluationResult, featureFlagName, key, stringify(options), withConfig, methodName, queue);
39
+ var treatment = processEvaluation(evaluationResult, featureFlagName, key, withConfig, methodName, queue, options);
40
40
  impressionsTracker.track(queue, attributes);
41
41
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
42
42
  return treatment;
43
43
  };
44
44
  var evaluation = readinessManager.isReadyFromCache() ?
45
- evaluateFeature(log, key, featureFlagName, attributes, storage, options) :
45
+ evaluateFeature(log, key, featureFlagName, attributes, storage) :
46
46
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
47
47
  Promise.resolve(treatmentNotReady) :
48
48
  treatmentNotReady;
@@ -58,16 +58,15 @@ export function clientFactory(params) {
58
58
  var wrapUp = function (evaluationResults) {
59
59
  var queue = [];
60
60
  var treatments = {};
61
- var properties = stringify(options);
62
61
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
63
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
62
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, withConfig, methodName, queue, options);
64
63
  });
65
64
  impressionsTracker.track(queue, attributes);
66
65
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
67
66
  return treatments;
68
67
  };
69
68
  var evaluations = readinessManager.isReadyFromCache() ?
70
- evaluateFeatures(log, key, featureFlagNames, attributes, storage, options) :
69
+ evaluateFeatures(log, key, featureFlagNames, attributes, storage) :
71
70
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
72
71
  Promise.resolve(treatmentsNotReady(featureFlagNames)) :
73
72
  treatmentsNotReady(featureFlagNames);
@@ -84,16 +83,15 @@ export function clientFactory(params) {
84
83
  var wrapUp = function (evaluationResults) {
85
84
  var queue = [];
86
85
  var treatments = {};
87
- var properties = stringify(options);
88
86
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
89
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
87
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, withConfig, methodName, queue, options);
90
88
  });
91
89
  impressionsTracker.track(queue, attributes);
92
90
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
93
91
  return treatments;
94
92
  };
95
93
  var evaluations = readinessManager.isReadyFromCache() ?
96
- evaluateFeaturesByFlagSets(log, key, flagSetNames, attributes, storage, methodName, options) :
94
+ evaluateFeaturesByFlagSets(log, key, flagSetNames, attributes, storage, methodName) :
97
95
  isAsync ?
98
96
  Promise.resolve({}) :
99
97
  {};
@@ -109,11 +107,14 @@ export function clientFactory(params) {
109
107
  return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, true, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
110
108
  }
111
109
  // Internal function
112
- function processEvaluation(evaluation, featureFlagName, key, properties, withConfig, invokingMethodName, queue) {
110
+ function processEvaluation(evaluation, featureFlagName, key, withConfig, invokingMethodName, queue, options) {
111
+ var _a;
112
+ if (options === void 0) { options = {}; }
113
113
  var matchingKey = getMatching(key);
114
114
  var bucketingKey = getBucketing(key);
115
- var changeNumber = evaluation.changeNumber, impressionsDisabled = evaluation.impressionsDisabled;
116
- var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
115
+ 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;
117
118
  if (treatment === CONTROL) {
118
119
  var fallbackTreatment = fallbackCalculator(featureFlagName, label);
119
120
  treatment = fallbackTreatment.treatment;
@@ -130,10 +131,10 @@ export function clientFactory(params) {
130
131
  time: Date.now(),
131
132
  bucketingKey: bucketingKey,
132
133
  label: label,
133
- changeNumber: changeNumber,
134
- properties: properties
134
+ changeNumber: definition.changeNumber,
135
+ properties: stringify(options.properties)
135
136
  },
136
- disabled: impressionsDisabled
137
+ disabled: options.impressionsDisabled || definition.impressionsDisabled
137
138
  });
138
139
  }
139
140
  if (withConfig) {
@@ -13,7 +13,7 @@ function isExpired(credential) {
13
13
  export function authProviderFactory(settings, splitHttpClient, telemetryTracker) {
14
14
  var urls = settings.urls, log = settings.log;
15
15
  function fetchAuth() {
16
- var url = "".concat(urls.auth, "/api/v3/auth?capabilities=config");
16
+ var url = "".concat(urls.auth, "/api/v3/auth?capabilities=config,aiconfig");
17
17
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN), false, true);
18
18
  }
19
19
  var authenticate = authenticateFactory(fetchAuth);
@@ -24,6 +24,7 @@ export function impressionsToJSON(impressions, metadata) {
24
24
  m: impression.time,
25
25
  pt: impression.pt,
26
26
  properties: impression.properties
27
+ // @TODO set entityType
27
28
  }
28
29
  };
29
30
  return JSON.stringify(impressionWithMetadata);