@splitsoftware/splitio-commons 2.1.1-rc.0 → 2.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.
- package/CHANGES.txt +3 -0
- package/README.md +0 -1
- package/cjs/evaluator/combiners/and.js +6 -2
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +5 -6
- package/cjs/evaluator/index.js +7 -7
- package/cjs/evaluator/matchers/index.js +1 -3
- package/cjs/evaluator/matchers/matcherTypes.js +0 -1
- package/cjs/evaluator/matchersTransform/index.js +0 -4
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +0 -1
- package/cjs/logger/constants.js +3 -4
- package/cjs/logger/messages/debug.js +2 -3
- package/cjs/logger/messages/error.js +1 -1
- package/cjs/logger/messages/warn.js +2 -2
- package/cjs/sdkClient/client.js +29 -19
- package/cjs/sdkClient/clientAttributesDecoration.js +19 -25
- package/cjs/sdkClient/clientInputValidation.js +28 -26
- package/cjs/services/splitApi.js +2 -2
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -5
- package/cjs/storages/KeyBuilder.js +0 -9
- package/cjs/storages/KeyBuilderCS.js +1 -4
- package/cjs/storages/KeyBuilderSS.js +0 -3
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/cjs/storages/inLocalStorage/index.js +0 -4
- package/cjs/storages/inMemory/InMemoryStorage.js +0 -3
- package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/cjs/storages/inRedis/index.js +0 -2
- package/cjs/storages/pluggable/index.js +0 -2
- package/cjs/storages/utils.js +1 -0
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +2 -2
- package/cjs/sync/polling/pollingManagerCS.js +7 -7
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +35 -51
- package/cjs/sync/streaming/SSEHandler/index.js +0 -1
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +77 -106
- package/cjs/sync/streaming/constants.js +1 -2
- package/cjs/sync/streaming/pushManager.js +16 -3
- package/cjs/sync/submitters/impressionsSubmitter.js +3 -2
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/trackers/strategy/strategyOptimized.js +3 -0
- package/cjs/utils/constants/index.js +2 -3
- package/cjs/utils/inputValidation/eventProperties.js +12 -1
- package/cjs/utils/inputValidation/index.js +3 -1
- package/esm/evaluator/combiners/and.js +6 -2
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +5 -6
- package/esm/evaluator/index.js +7 -7
- package/esm/evaluator/matchers/index.js +1 -3
- package/esm/evaluator/matchers/matcherTypes.js +0 -1
- package/esm/evaluator/matchersTransform/index.js +0 -4
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +0 -1
- package/esm/logger/constants.js +0 -1
- package/esm/logger/messages/debug.js +2 -3
- package/esm/logger/messages/error.js +1 -1
- package/esm/logger/messages/warn.js +2 -2
- package/esm/sdkClient/client.js +29 -19
- package/esm/sdkClient/clientAttributesDecoration.js +19 -25
- package/esm/sdkClient/clientInputValidation.js +29 -27
- package/esm/services/splitApi.js +2 -2
- package/esm/storages/AbstractSplitsCacheSync.js +2 -5
- package/esm/storages/KeyBuilder.js +0 -9
- package/esm/storages/KeyBuilderCS.js +1 -4
- package/esm/storages/KeyBuilderSS.js +0 -3
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/esm/storages/inLocalStorage/index.js +0 -4
- package/esm/storages/inMemory/InMemoryStorage.js +0 -3
- package/esm/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/esm/storages/inRedis/index.js +0 -2
- package/esm/storages/pluggable/index.js +0 -2
- package/esm/storages/utils.js +1 -0
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +2 -2
- package/esm/sync/polling/pollingManagerCS.js +7 -7
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +35 -51
- package/esm/sync/streaming/SSEHandler/index.js +1 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +73 -102
- package/esm/sync/streaming/constants.js +0 -1
- package/esm/sync/streaming/pushManager.js +19 -6
- package/esm/sync/submitters/impressionsSubmitter.js +3 -2
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/trackers/strategy/strategyOptimized.js +3 -0
- package/esm/utils/constants/index.js +1 -2
- package/esm/utils/inputValidation/eventProperties.js +10 -0
- package/esm/utils/inputValidation/index.js +1 -0
- package/package.json +1 -1
- package/src/dtos/types.ts +8 -32
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/and.ts +4 -5
- package/src/evaluator/combiners/ifelseif.ts +9 -7
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +12 -12
- package/src/evaluator/index.ts +7 -7
- package/src/evaluator/matchers/index.ts +1 -3
- package/src/evaluator/matchers/matcherTypes.ts +0 -1
- package/src/evaluator/matchersTransform/index.ts +0 -3
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +4 -5
- package/src/logger/constants.ts +0 -1
- package/src/logger/messages/debug.ts +2 -3
- package/src/logger/messages/error.ts +1 -1
- package/src/logger/messages/warn.ts +2 -2
- package/src/sdkClient/client.ts +31 -21
- package/src/sdkClient/clientAttributesDecoration.ts +20 -27
- package/src/sdkClient/clientInputValidation.ts +30 -27
- package/src/sdkManager/index.ts +1 -1
- package/src/services/splitApi.ts +2 -2
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +3 -6
- package/src/storages/KeyBuilder.ts +0 -12
- package/src/storages/KeyBuilderCS.ts +1 -5
- package/src/storages/KeyBuilderSS.ts +0 -4
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +14 -10
- package/src/storages/inLocalStorage/index.ts +0 -4
- package/src/storages/inMemory/InMemoryStorage.ts +0 -3
- package/src/storages/inMemory/InMemoryStorageCS.ts +0 -4
- package/src/storages/inRedis/index.ts +0 -2
- package/src/storages/pluggable/index.ts +0 -2
- package/src/storages/types.ts +1 -33
- package/src/storages/utils.ts +1 -0
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +1 -2
- package/src/sync/polling/fetchers/types.ts +0 -1
- package/src/sync/polling/pollingManagerCS.ts +7 -7
- package/src/sync/polling/types.ts +2 -2
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +44 -61
- package/src/sync/streaming/SSEHandler/index.ts +1 -2
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +68 -98
- package/src/sync/streaming/constants.ts +0 -1
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +18 -6
- package/src/sync/streaming/types.ts +2 -3
- package/src/sync/submitters/impressionsSubmitter.ts +3 -2
- package/src/sync/submitters/types.ts +23 -33
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/trackers/strategy/strategyOptimized.ts +3 -0
- package/src/utils/constants/index.ts +1 -2
- package/src/utils/inputValidation/eventProperties.ts +10 -0
- package/src/utils/inputValidation/index.ts +1 -0
- package/src/utils/lang/index.ts +1 -1
- package/types/splitio.d.ts +100 -35
- package/cjs/evaluator/matchers/rbsegment.js +0 -43
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -117
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +0 -61
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +0 -64
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +0 -64
- package/esm/evaluator/matchers/rbsegment.js +0 -39
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -114
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +0 -58
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +0 -61
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +0 -61
- package/src/evaluator/matchers/rbsegment.ts +0 -61
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +0 -136
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +0 -68
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +0 -79
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +0 -76
|
@@ -18,6 +18,9 @@ export function strategyOptimizedFactory(
|
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
20
|
process(impression: SplitIO.ImpressionDTO) {
|
|
21
|
+
// DEBUG mode without previous time, for impressions with properties
|
|
22
|
+
if (impression.properties) return true;
|
|
23
|
+
|
|
21
24
|
impression.pt = impressionsObserver.testAndSet(impression);
|
|
22
25
|
|
|
23
26
|
const now = Date.now();
|
|
@@ -104,9 +104,8 @@ export const DISABLED = 0;
|
|
|
104
104
|
export const ENABLED = 1;
|
|
105
105
|
export const PAUSED = 2;
|
|
106
106
|
|
|
107
|
-
export const FLAG_SPEC_VERSION = '1.
|
|
107
|
+
export const FLAG_SPEC_VERSION = '1.2';
|
|
108
108
|
|
|
109
109
|
// Matcher types
|
|
110
110
|
export const IN_SEGMENT = 'IN_SEGMENT';
|
|
111
111
|
export const IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
|
|
112
|
-
export const IN_RULE_BASED_SEGMENT = 'IN_RULE_BASED_SEGMENT';
|
|
@@ -66,3 +66,13 @@ export function validateEventProperties(log: ILogger, maybeProperties: any, meth
|
|
|
66
66
|
|
|
67
67
|
return output;
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
export function validateEvaluationOptions(log: ILogger, maybeOptions: any, method: string): SplitIO.EvaluationOptions | undefined {
|
|
71
|
+
if (isObject(maybeOptions)) {
|
|
72
|
+
const properties = validateEventProperties(log, maybeOptions.properties, method).properties;
|
|
73
|
+
return properties && Object.keys(properties).length > 0 ? { properties } : undefined;
|
|
74
|
+
} else if (maybeOptions) {
|
|
75
|
+
log.error(ERROR_NOT_PLAIN_OBJECT, [method, 'evaluation options']);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
@@ -11,3 +11,4 @@ export { validateIfNotDestroyed, validateIfOperational } from './isOperational';
|
|
|
11
11
|
export { validateSplitExistence } from './splitExistence';
|
|
12
12
|
export { validateTrafficTypeExistence } from './trafficTypeExistence';
|
|
13
13
|
export { validatePreloadedData } from './preloadedData';
|
|
14
|
+
export { validateEvaluationOptions } from './eventProperties';
|
package/src/utils/lang/index.ts
CHANGED
|
@@ -111,7 +111,7 @@ export function groupBy<T extends Record<string, any>>(source: T[], prop: string
|
|
|
111
111
|
/**
|
|
112
112
|
* Checks if a given value is a boolean.
|
|
113
113
|
*/
|
|
114
|
-
export function isBoolean(val: any):
|
|
114
|
+
export function isBoolean(val: any): boolean {
|
|
115
115
|
return val === true || val === false;
|
|
116
116
|
}
|
|
117
117
|
|
package/types/splitio.d.ts
CHANGED
|
@@ -778,6 +778,12 @@ declare namespace SplitIO {
|
|
|
778
778
|
type Properties = {
|
|
779
779
|
[propertyName: string]: string | number | boolean | null;
|
|
780
780
|
};
|
|
781
|
+
/**
|
|
782
|
+
* Evaluation options object for getTreatment methods.
|
|
783
|
+
*/
|
|
784
|
+
type EvaluationOptions = {
|
|
785
|
+
properties?: Properties;
|
|
786
|
+
}
|
|
781
787
|
/**
|
|
782
788
|
* The SplitKey object format.
|
|
783
789
|
*/
|
|
@@ -803,14 +809,42 @@ declare namespace SplitIO {
|
|
|
803
809
|
* Impression DTO generated by the SDK when processing evaluations.
|
|
804
810
|
*/
|
|
805
811
|
type ImpressionDTO = {
|
|
812
|
+
/**
|
|
813
|
+
* Feature flag name.
|
|
814
|
+
*/
|
|
806
815
|
feature: string;
|
|
816
|
+
/**
|
|
817
|
+
* Key.
|
|
818
|
+
*/
|
|
807
819
|
keyName: string;
|
|
820
|
+
/**
|
|
821
|
+
* Treatment value.
|
|
822
|
+
*/
|
|
808
823
|
treatment: string;
|
|
824
|
+
/**
|
|
825
|
+
* Impression timestamp.
|
|
826
|
+
*/
|
|
809
827
|
time: number;
|
|
828
|
+
/**
|
|
829
|
+
* Bucketing Key
|
|
830
|
+
*/
|
|
810
831
|
bucketingKey?: string;
|
|
832
|
+
/**
|
|
833
|
+
* Rule label
|
|
834
|
+
*/
|
|
811
835
|
label: string;
|
|
836
|
+
/**
|
|
837
|
+
* Version of the feature flag
|
|
838
|
+
*/
|
|
812
839
|
changeNumber: number;
|
|
840
|
+
/**
|
|
841
|
+
* Previous time
|
|
842
|
+
*/
|
|
813
843
|
pt?: number;
|
|
844
|
+
/**
|
|
845
|
+
* JSON stringified version of the impression properties.
|
|
846
|
+
*/
|
|
847
|
+
properties?: string;
|
|
814
848
|
}
|
|
815
849
|
/**
|
|
816
850
|
* Object with information about an impression. It contains the generated impression DTO as well as
|
|
@@ -1514,73 +1548,80 @@ declare namespace SplitIO {
|
|
|
1514
1548
|
* @param key - The string key representing the consumer.
|
|
1515
1549
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1516
1550
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1551
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1517
1552
|
* @returns The treatment string.
|
|
1518
1553
|
*/
|
|
1519
|
-
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): Treatment;
|
|
1554
|
+
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): Treatment;
|
|
1520
1555
|
/**
|
|
1521
1556
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1522
1557
|
*
|
|
1523
1558
|
* @param key - The string key representing the consumer.
|
|
1524
1559
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1525
1560
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1526
|
-
* @
|
|
1527
|
-
*
|
|
1561
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1562
|
+
* @returns The TreatmentWithConfig object that contains the treatment string and the configuration stringified JSON (or null if there was no config for that treatment).
|
|
1528
1563
|
*/
|
|
1529
|
-
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
1564
|
+
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentWithConfig;
|
|
1530
1565
|
/**
|
|
1531
1566
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1532
1567
|
*
|
|
1533
1568
|
* @param key - The string key representing the consumer.
|
|
1534
1569
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1535
1570
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1571
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1536
1572
|
* @returns The treatments object map.
|
|
1537
1573
|
*/
|
|
1538
|
-
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
1574
|
+
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1539
1575
|
/**
|
|
1540
1576
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1541
1577
|
*
|
|
1542
1578
|
* @param key - The string key representing the consumer.
|
|
1543
1579
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1544
1580
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1581
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1545
1582
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1546
1583
|
*/
|
|
1547
|
-
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1584
|
+
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1548
1585
|
/**
|
|
1549
1586
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1550
1587
|
*
|
|
1551
1588
|
* @param key - The string key representing the consumer.
|
|
1552
1589
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1553
1590
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1591
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1554
1592
|
* @returns The map with all the Treatment objects
|
|
1555
1593
|
*/
|
|
1556
|
-
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments;
|
|
1594
|
+
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1557
1595
|
/**
|
|
1558
1596
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1559
1597
|
*
|
|
1560
1598
|
* @param key - The string key representing the consumer.
|
|
1561
1599
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1562
1600
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1601
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1563
1602
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1564
1603
|
*/
|
|
1565
|
-
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
1604
|
+
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1566
1605
|
/**
|
|
1567
1606
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1568
1607
|
*
|
|
1569
1608
|
* @param key - The string key representing the consumer.
|
|
1570
1609
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1571
1610
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1611
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1572
1612
|
* @returns The map with all the Treatment objects
|
|
1573
1613
|
*/
|
|
1574
|
-
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments;
|
|
1614
|
+
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1575
1615
|
/**
|
|
1576
1616
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1577
1617
|
*
|
|
1578
1618
|
* @param key - The string key representing the consumer.
|
|
1579
1619
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1580
1620
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1621
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1581
1622
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1582
1623
|
*/
|
|
1583
|
-
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1624
|
+
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1584
1625
|
/**
|
|
1585
1626
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1586
1627
|
*
|
|
@@ -1605,72 +1646,80 @@ declare namespace SplitIO {
|
|
|
1605
1646
|
* @param key - The string key representing the consumer.
|
|
1606
1647
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1607
1648
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1649
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1608
1650
|
* @returns Treatment promise that resolves to the treatment string.
|
|
1609
1651
|
*/
|
|
1610
|
-
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
1652
|
+
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatment;
|
|
1611
1653
|
/**
|
|
1612
1654
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1613
1655
|
*
|
|
1614
1656
|
* @param key - The string key representing the consumer.
|
|
1615
1657
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1616
1658
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1659
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1617
1660
|
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1618
1661
|
*/
|
|
1619
|
-
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
1662
|
+
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentWithConfig;
|
|
1620
1663
|
/**
|
|
1621
1664
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1622
1665
|
*
|
|
1623
1666
|
* @param key - The string key representing the consumer.
|
|
1624
1667
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1625
1668
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1669
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1626
1670
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1627
1671
|
*/
|
|
1628
|
-
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
1672
|
+
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1629
1673
|
/**
|
|
1630
1674
|
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1631
1675
|
*
|
|
1632
1676
|
* @param key - The string key representing the consumer.
|
|
1633
1677
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1634
1678
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1679
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1635
1680
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1636
1681
|
*/
|
|
1637
|
-
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1682
|
+
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1638
1683
|
/**
|
|
1639
1684
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1640
1685
|
*
|
|
1641
1686
|
* @param key - The string key representing the consumer.
|
|
1642
1687
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1643
1688
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1689
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1644
1690
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1645
1691
|
*/
|
|
1646
|
-
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
1692
|
+
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1647
1693
|
/**
|
|
1648
1694
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1649
1695
|
*
|
|
1650
1696
|
* @param key - The string key representing the consumer.
|
|
1651
1697
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1652
1698
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1699
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1653
1700
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1654
1701
|
*/
|
|
1655
|
-
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1702
|
+
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1656
1703
|
/**
|
|
1657
1704
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1658
1705
|
*
|
|
1659
1706
|
* @param key - The string key representing the consumer.
|
|
1660
1707
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1661
1708
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1709
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1662
1710
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1663
1711
|
*/
|
|
1664
|
-
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
1712
|
+
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1665
1713
|
/**
|
|
1666
1714
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1667
1715
|
*
|
|
1668
1716
|
* @param key - The string key representing the consumer.
|
|
1669
1717
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1670
1718
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1719
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1671
1720
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1672
1721
|
*/
|
|
1673
|
-
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1722
|
+
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1674
1723
|
/**
|
|
1675
1724
|
* Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
|
|
1676
1725
|
*
|
|
@@ -1735,65 +1784,73 @@ declare namespace SplitIO {
|
|
|
1735
1784
|
*
|
|
1736
1785
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1737
1786
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1787
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1738
1788
|
* @returns The treatment string.
|
|
1739
1789
|
*/
|
|
1740
|
-
getTreatment(featureFlagName: string, attributes?: Attributes): Treatment;
|
|
1790
|
+
getTreatment(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): Treatment;
|
|
1741
1791
|
/**
|
|
1742
1792
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1743
1793
|
*
|
|
1744
1794
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1745
1795
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1746
|
-
* @
|
|
1796
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1797
|
+
* @returns The TreatmentWithConfig object that contains the treatment string and the configuration stringified JSON (or null if there was no config for that treatment).
|
|
1747
1798
|
*/
|
|
1748
|
-
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
1799
|
+
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentWithConfig;
|
|
1749
1800
|
/**
|
|
1750
1801
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1751
1802
|
*
|
|
1752
1803
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1753
1804
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1805
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1754
1806
|
* @returns The treatments object map.
|
|
1755
1807
|
*/
|
|
1756
|
-
getTreatments(featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
1808
|
+
getTreatments(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1757
1809
|
/**
|
|
1758
1810
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1759
1811
|
*
|
|
1760
1812
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1761
1813
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1814
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1762
1815
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1763
1816
|
*/
|
|
1764
|
-
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1817
|
+
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1765
1818
|
/**
|
|
1766
1819
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1767
1820
|
*
|
|
1768
1821
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1769
1822
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1823
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1770
1824
|
* @returns The map with all the Treatments objects
|
|
1771
1825
|
*/
|
|
1772
|
-
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments;
|
|
1826
|
+
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1773
1827
|
/**
|
|
1774
1828
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1775
1829
|
*
|
|
1776
1830
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1777
1831
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1832
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1778
1833
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1779
1834
|
*/
|
|
1780
|
-
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
1835
|
+
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1781
1836
|
/**
|
|
1782
1837
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1783
1838
|
*
|
|
1784
1839
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1785
1840
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1841
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1786
1842
|
* @returns The map with all the Treatments objects
|
|
1787
1843
|
*/
|
|
1788
|
-
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments;
|
|
1844
|
+
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1789
1845
|
/**
|
|
1790
1846
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1791
1847
|
*
|
|
1792
1848
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1793
1849
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1850
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1794
1851
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1795
1852
|
*/
|
|
1796
|
-
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1853
|
+
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1797
1854
|
/**
|
|
1798
1855
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1799
1856
|
*
|
|
@@ -1814,65 +1871,73 @@ declare namespace SplitIO {
|
|
|
1814
1871
|
*
|
|
1815
1872
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1816
1873
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1874
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1817
1875
|
* @returns Treatment promise that resolves to the treatment string.
|
|
1818
1876
|
*/
|
|
1819
|
-
getTreatment(featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
1877
|
+
getTreatment(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatment;
|
|
1820
1878
|
/**
|
|
1821
1879
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1822
1880
|
*
|
|
1823
1881
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1824
1882
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1883
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1825
1884
|
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1826
1885
|
*/
|
|
1827
|
-
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
1886
|
+
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentWithConfig;
|
|
1828
1887
|
/**
|
|
1829
1888
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1830
1889
|
*
|
|
1831
1890
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1832
1891
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1892
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1833
1893
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1834
1894
|
*/
|
|
1835
|
-
getTreatments(featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
1895
|
+
getTreatments(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1836
1896
|
/**
|
|
1837
1897
|
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1838
1898
|
*
|
|
1839
1899
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1840
1900
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1901
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1841
1902
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1842
1903
|
*/
|
|
1843
|
-
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1904
|
+
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1844
1905
|
/**
|
|
1845
1906
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1846
1907
|
*
|
|
1847
1908
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1848
1909
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1910
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1849
1911
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1850
1912
|
*/
|
|
1851
|
-
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
1913
|
+
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1852
1914
|
/**
|
|
1853
1915
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1854
1916
|
*
|
|
1855
1917
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1856
1918
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1919
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1857
1920
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1858
1921
|
*/
|
|
1859
|
-
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1922
|
+
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1860
1923
|
/**
|
|
1861
1924
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1862
1925
|
*
|
|
1863
1926
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1864
1927
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1928
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1865
1929
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1866
1930
|
*/
|
|
1867
|
-
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
1931
|
+
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1868
1932
|
/**
|
|
1869
1933
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1870
1934
|
*
|
|
1871
1935
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1872
1936
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1937
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1873
1938
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1874
1939
|
*/
|
|
1875
|
-
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1940
|
+
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1876
1941
|
/**
|
|
1877
1942
|
* Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
|
|
1878
1943
|
*
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ruleBasedSegmentMatcherContext = void 0;
|
|
4
|
-
var thenable_1 = require("../../utils/promise/thenable");
|
|
5
|
-
var key_1 = require("../../utils/key");
|
|
6
|
-
var parser_1 = require("../parser");
|
|
7
|
-
function ruleBasedSegmentMatcherContext(segmentName, storage, log) {
|
|
8
|
-
return function ruleBasedSegmentMatcher(_a, splitEvaluator) {
|
|
9
|
-
var key = _a.key, attributes = _a.attributes;
|
|
10
|
-
function matchConditions(rbsegment) {
|
|
11
|
-
var conditions = rbsegment.conditions;
|
|
12
|
-
var evaluator = (0, parser_1.parser)(log, conditions, storage);
|
|
13
|
-
var evaluation = evaluator((0, key_1.keyParser)(key), undefined, undefined, undefined, attributes, splitEvaluator);
|
|
14
|
-
return (0, thenable_1.thenable)(evaluation) ?
|
|
15
|
-
evaluation.then(function (evaluation) { return evaluation ? true : false; }) :
|
|
16
|
-
evaluation ? true : false;
|
|
17
|
-
}
|
|
18
|
-
function isExcluded(rbSegment) {
|
|
19
|
-
var matchingKey = (0, key_1.getMatching)(key);
|
|
20
|
-
if (rbSegment.excluded.keys.indexOf(matchingKey) !== -1)
|
|
21
|
-
return true;
|
|
22
|
-
var isInSegment = rbSegment.excluded.segments.map(function (segmentName) {
|
|
23
|
-
return storage.segments.isInSegment(segmentName, matchingKey);
|
|
24
|
-
});
|
|
25
|
-
return isInSegment.length && (0, thenable_1.thenable)(isInSegment[0]) ?
|
|
26
|
-
Promise.all(isInSegment).then(function (results) { return results.some(function (result) { return result; }); }) :
|
|
27
|
-
isInSegment.some(function (result) { return result; });
|
|
28
|
-
}
|
|
29
|
-
function isInSegment(rbSegment) {
|
|
30
|
-
if (!rbSegment)
|
|
31
|
-
return false;
|
|
32
|
-
var excluded = isExcluded(rbSegment);
|
|
33
|
-
return (0, thenable_1.thenable)(excluded) ?
|
|
34
|
-
excluded.then(function (excluded) { return excluded ? false : matchConditions(rbSegment); }) :
|
|
35
|
-
excluded ? false : matchConditions(rbSegment);
|
|
36
|
-
}
|
|
37
|
-
var rbSegment = storage.rbSegments.get(segmentName);
|
|
38
|
-
return (0, thenable_1.thenable)(rbSegment) ?
|
|
39
|
-
rbSegment.then(isInSegment) :
|
|
40
|
-
isInSegment(rbSegment);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
exports.ruleBasedSegmentMatcherContext = ruleBasedSegmentMatcherContext;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RBSegmentsCacheInLocal = void 0;
|
|
4
|
-
var lang_1 = require("../../utils/lang");
|
|
5
|
-
var sets_1 = require("../../utils/lang/sets");
|
|
6
|
-
var AbstractSplitsCacheSync_1 = require("../AbstractSplitsCacheSync");
|
|
7
|
-
var constants_1 = require("./constants");
|
|
8
|
-
var RBSegmentsCacheInLocal = /** @class */ (function () {
|
|
9
|
-
function RBSegmentsCacheInLocal(settings, keys) {
|
|
10
|
-
this.keys = keys;
|
|
11
|
-
this.log = settings.log;
|
|
12
|
-
}
|
|
13
|
-
RBSegmentsCacheInLocal.prototype.clear = function () {
|
|
14
|
-
var _this = this;
|
|
15
|
-
this.getNames().forEach(function (name) { return _this.remove(name); });
|
|
16
|
-
localStorage.removeItem(this.keys.buildRBSegmentsTillKey());
|
|
17
|
-
};
|
|
18
|
-
RBSegmentsCacheInLocal.prototype.update = function (toAdd, toRemove, changeNumber) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
this.setChangeNumber(changeNumber);
|
|
21
|
-
var updated = toAdd.map(function (toAdd) { return _this.add(toAdd); }).some(function (result) { return result; });
|
|
22
|
-
return toRemove.map(function (toRemove) { return _this.remove(toRemove.name); }).some(function (result) { return result; }) || updated;
|
|
23
|
-
};
|
|
24
|
-
RBSegmentsCacheInLocal.prototype.setChangeNumber = function (changeNumber) {
|
|
25
|
-
try {
|
|
26
|
-
localStorage.setItem(this.keys.buildRBSegmentsTillKey(), changeNumber + '');
|
|
27
|
-
localStorage.setItem(this.keys.buildLastUpdatedKey(), Date.now() + '');
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
this.log.error(constants_1.LOG_PREFIX + e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
RBSegmentsCacheInLocal.prototype.updateSegmentCount = function (diff) {
|
|
34
|
-
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
35
|
-
var count = (0, lang_1.toNumber)(localStorage.getItem(segmentsCountKey)) + diff;
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
if (count > 0)
|
|
38
|
-
localStorage.setItem(segmentsCountKey, count);
|
|
39
|
-
else
|
|
40
|
-
localStorage.removeItem(segmentsCountKey);
|
|
41
|
-
};
|
|
42
|
-
RBSegmentsCacheInLocal.prototype.add = function (rbSegment) {
|
|
43
|
-
try {
|
|
44
|
-
var name_1 = rbSegment.name;
|
|
45
|
-
var rbSegmentKey = this.keys.buildRBSegmentKey(name_1);
|
|
46
|
-
var rbSegmentFromLocalStorage = localStorage.getItem(rbSegmentKey);
|
|
47
|
-
var previous = rbSegmentFromLocalStorage ? JSON.parse(rbSegmentFromLocalStorage) : null;
|
|
48
|
-
localStorage.setItem(rbSegmentKey, JSON.stringify(rbSegment));
|
|
49
|
-
var usesSegmentsDiff = 0;
|
|
50
|
-
if (previous && (0, AbstractSplitsCacheSync_1.usesSegments)(previous))
|
|
51
|
-
usesSegmentsDiff--;
|
|
52
|
-
if ((0, AbstractSplitsCacheSync_1.usesSegments)(rbSegment))
|
|
53
|
-
usesSegmentsDiff++;
|
|
54
|
-
if (usesSegmentsDiff !== 0)
|
|
55
|
-
this.updateSegmentCount(usesSegmentsDiff);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
this.log.error(constants_1.LOG_PREFIX + e);
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
RBSegmentsCacheInLocal.prototype.remove = function (name) {
|
|
64
|
-
try {
|
|
65
|
-
var rbSegment = this.get(name);
|
|
66
|
-
if (!rbSegment)
|
|
67
|
-
return false;
|
|
68
|
-
localStorage.removeItem(this.keys.buildRBSegmentKey(name));
|
|
69
|
-
if ((0, AbstractSplitsCacheSync_1.usesSegments)(rbSegment))
|
|
70
|
-
this.updateSegmentCount(-1);
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
this.log.error(constants_1.LOG_PREFIX + e);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
RBSegmentsCacheInLocal.prototype.getNames = function () {
|
|
79
|
-
var len = localStorage.length;
|
|
80
|
-
var accum = [];
|
|
81
|
-
var cur = 0;
|
|
82
|
-
while (cur < len) {
|
|
83
|
-
var key = localStorage.key(cur);
|
|
84
|
-
if (key != null && this.keys.isRBSegmentKey(key))
|
|
85
|
-
accum.push(this.keys.extractKey(key));
|
|
86
|
-
cur++;
|
|
87
|
-
}
|
|
88
|
-
return accum;
|
|
89
|
-
};
|
|
90
|
-
RBSegmentsCacheInLocal.prototype.get = function (name) {
|
|
91
|
-
var item = localStorage.getItem(this.keys.buildRBSegmentKey(name));
|
|
92
|
-
return item && JSON.parse(item);
|
|
93
|
-
};
|
|
94
|
-
RBSegmentsCacheInLocal.prototype.contains = function (names) {
|
|
95
|
-
var namesArray = (0, sets_1.setToArray)(names);
|
|
96
|
-
var namesInStorage = this.getNames();
|
|
97
|
-
return namesArray.every(function (name) { return namesInStorage.indexOf(name) !== -1; });
|
|
98
|
-
};
|
|
99
|
-
RBSegmentsCacheInLocal.prototype.getChangeNumber = function () {
|
|
100
|
-
var n = -1;
|
|
101
|
-
var value = localStorage.getItem(this.keys.buildRBSegmentsTillKey());
|
|
102
|
-
if (value !== null) {
|
|
103
|
-
value = parseInt(value, 10);
|
|
104
|
-
return (0, lang_1.isNaNNumber)(value) ? n : value;
|
|
105
|
-
}
|
|
106
|
-
return n;
|
|
107
|
-
};
|
|
108
|
-
RBSegmentsCacheInLocal.prototype.usesSegments = function () {
|
|
109
|
-
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
110
|
-
var splitsWithSegmentsCount = storedCount === null ? 0 : (0, lang_1.toNumber)(storedCount);
|
|
111
|
-
return (0, lang_1.isFiniteNumber)(splitsWithSegmentsCount) ?
|
|
112
|
-
splitsWithSegmentsCount > 0 :
|
|
113
|
-
true;
|
|
114
|
-
};
|
|
115
|
-
return RBSegmentsCacheInLocal;
|
|
116
|
-
}());
|
|
117
|
-
exports.RBSegmentsCacheInLocal = RBSegmentsCacheInLocal;
|