@splitsoftware/splitio-commons 2.1.1-rc.0 → 2.1.1-rc.2
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 +7 -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/readiness/readinessManager.js +6 -0
- 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/AbstractSplitsCacheAsync.js +0 -7
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -12
- package/cjs/storages/KeyBuilder.js +0 -9
- package/cjs/storages/KeyBuilderCS.js +4 -4
- package/cjs/storages/KeyBuilderSS.js +0 -3
- package/cjs/storages/dataLoader.js +3 -2
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +23 -76
- package/cjs/storages/inLocalStorage/index.js +5 -7
- package/cjs/storages/inLocalStorage/validateCache.js +79 -0
- 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 +2 -3
- package/cjs/storages/utils.js +1 -0
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +3 -2
- 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 +33 -60
- 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 +10 -5
- package/cjs/trackers/strategy/strategyDebug.js +2 -0
- 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/cjs/utils/settingsValidation/storage/storageCS.js +1 -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/readiness/readinessManager.js +6 -0
- 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/AbstractSplitsCacheAsync.js +0 -7
- package/esm/storages/AbstractSplitsCacheSync.js +2 -12
- package/esm/storages/KeyBuilder.js +0 -9
- package/esm/storages/KeyBuilderCS.js +4 -4
- package/esm/storages/KeyBuilderSS.js +0 -3
- package/esm/storages/dataLoader.js +2 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +23 -76
- package/esm/storages/inLocalStorage/index.js +5 -7
- package/esm/storages/inLocalStorage/validateCache.js +75 -0
- 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 +2 -3
- package/esm/storages/utils.js +1 -0
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +3 -2
- 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 +34 -61
- 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 +10 -5
- package/esm/trackers/strategy/strategyDebug.js +2 -0
- 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/esm/utils/settingsValidation/storage/storageCS.js +1 -1
- 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/readiness/readinessManager.ts +5 -0
- 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/AbstractSplitsCacheAsync.ts +0 -8
- package/src/storages/AbstractSplitsCacheSync.ts +3 -14
- package/src/storages/KeyBuilder.ts +0 -12
- package/src/storages/KeyBuilderCS.ts +5 -5
- package/src/storages/KeyBuilderSS.ts +0 -4
- package/src/storages/dataLoader.ts +3 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +26 -87
- package/src/storages/inLocalStorage/index.ts +8 -12
- package/src/storages/inLocalStorage/validateCache.ts +91 -0
- 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 +2 -3
- package/src/storages/types.ts +2 -37
- package/src/storages/utils.ts +1 -0
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +6 -5
- 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 +43 -71
- 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 +11 -5
- package/src/trackers/strategy/strategyDebug.ts +2 -0
- 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 +2 -2
- package/src/utils/settingsValidation/storage/storageCS.ts +1 -1
- package/types/splitio.d.ts +128 -36
- 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/cjs/utils/constants/browser.js +0 -5
- 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/esm/utils/constants/browser.js +0 -2
- 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
- package/src/utils/constants/browser.ts +0 -2
package/types/splitio.d.ts
CHANGED
|
@@ -778,6 +778,15 @@ 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
|
+
/**
|
|
786
|
+
* Optional properties to append to the generated impression object sent to Split backend.
|
|
787
|
+
*/
|
|
788
|
+
properties?: Properties;
|
|
789
|
+
}
|
|
781
790
|
/**
|
|
782
791
|
* The SplitKey object format.
|
|
783
792
|
*/
|
|
@@ -803,14 +812,42 @@ declare namespace SplitIO {
|
|
|
803
812
|
* Impression DTO generated by the SDK when processing evaluations.
|
|
804
813
|
*/
|
|
805
814
|
type ImpressionDTO = {
|
|
815
|
+
/**
|
|
816
|
+
* Feature flag name.
|
|
817
|
+
*/
|
|
806
818
|
feature: string;
|
|
819
|
+
/**
|
|
820
|
+
* Key.
|
|
821
|
+
*/
|
|
807
822
|
keyName: string;
|
|
823
|
+
/**
|
|
824
|
+
* Treatment value.
|
|
825
|
+
*/
|
|
808
826
|
treatment: string;
|
|
827
|
+
/**
|
|
828
|
+
* Impression timestamp.
|
|
829
|
+
*/
|
|
809
830
|
time: number;
|
|
831
|
+
/**
|
|
832
|
+
* Bucketing Key
|
|
833
|
+
*/
|
|
810
834
|
bucketingKey?: string;
|
|
835
|
+
/**
|
|
836
|
+
* Rule label
|
|
837
|
+
*/
|
|
811
838
|
label: string;
|
|
839
|
+
/**
|
|
840
|
+
* Version of the feature flag
|
|
841
|
+
*/
|
|
812
842
|
changeNumber: number;
|
|
843
|
+
/**
|
|
844
|
+
* Previous time
|
|
845
|
+
*/
|
|
813
846
|
pt?: number;
|
|
847
|
+
/**
|
|
848
|
+
* JSON stringified version of the impression properties.
|
|
849
|
+
*/
|
|
850
|
+
properties?: string;
|
|
814
851
|
}
|
|
815
852
|
/**
|
|
816
853
|
* Object with information about an impression. It contains the generated impression DTO as well as
|
|
@@ -910,6 +947,18 @@ declare namespace SplitIO {
|
|
|
910
947
|
* @defaultValue `'SPLITIO'`
|
|
911
948
|
*/
|
|
912
949
|
prefix?: string;
|
|
950
|
+
/**
|
|
951
|
+
* Number of days before cached data expires if it was not updated. If cache expires, it is cleared on initialization.
|
|
952
|
+
*
|
|
953
|
+
* @defaultValue `10`
|
|
954
|
+
*/
|
|
955
|
+
expirationDays?: number;
|
|
956
|
+
/**
|
|
957
|
+
* Optional settings to clear the cache. If set to `true`, the SDK clears the cached data on initialization, unless the cache was cleared within the last 24 hours.
|
|
958
|
+
*
|
|
959
|
+
* @defaultValue `false`
|
|
960
|
+
*/
|
|
961
|
+
clearOnInit?: boolean;
|
|
913
962
|
}
|
|
914
963
|
/**
|
|
915
964
|
* Storage for asynchronous (consumer) SDK.
|
|
@@ -1233,11 +1282,23 @@ declare namespace SplitIO {
|
|
|
1233
1282
|
*/
|
|
1234
1283
|
type?: BrowserStorage;
|
|
1235
1284
|
/**
|
|
1236
|
-
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
1285
|
+
* Optional prefix to prevent any kind of data collision between SDK versions when using 'LOCALSTORAGE'.
|
|
1237
1286
|
*
|
|
1238
1287
|
* @defaultValue `'SPLITIO'`
|
|
1239
1288
|
*/
|
|
1240
1289
|
prefix?: string;
|
|
1290
|
+
/**
|
|
1291
|
+
* Optional settings for the 'LOCALSTORAGE' storage type. It specifies the number of days before cached data expires if it was not updated. If cache expires, it is cleared on initialization.
|
|
1292
|
+
*
|
|
1293
|
+
* @defaultValue `10`
|
|
1294
|
+
*/
|
|
1295
|
+
expirationDays?: number;
|
|
1296
|
+
/**
|
|
1297
|
+
* Optional settings for the 'LOCALSTORAGE' storage type. If set to `true`, the SDK clears the cached data on initialization, unless the cache was cleared within the last 24 hours.
|
|
1298
|
+
*
|
|
1299
|
+
* @defaultValue `false`
|
|
1300
|
+
*/
|
|
1301
|
+
clearOnInit?: boolean;
|
|
1241
1302
|
};
|
|
1242
1303
|
}
|
|
1243
1304
|
/**
|
|
@@ -1514,73 +1575,80 @@ declare namespace SplitIO {
|
|
|
1514
1575
|
* @param key - The string key representing the consumer.
|
|
1515
1576
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1516
1577
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1578
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1517
1579
|
* @returns The treatment string.
|
|
1518
1580
|
*/
|
|
1519
|
-
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): Treatment;
|
|
1581
|
+
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): Treatment;
|
|
1520
1582
|
/**
|
|
1521
1583
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1522
1584
|
*
|
|
1523
1585
|
* @param key - The string key representing the consumer.
|
|
1524
1586
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1525
1587
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1526
|
-
* @
|
|
1527
|
-
*
|
|
1588
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1589
|
+
* @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
1590
|
*/
|
|
1529
|
-
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
1591
|
+
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentWithConfig;
|
|
1530
1592
|
/**
|
|
1531
1593
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1532
1594
|
*
|
|
1533
1595
|
* @param key - The string key representing the consumer.
|
|
1534
1596
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1535
1597
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1598
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1536
1599
|
* @returns The treatments object map.
|
|
1537
1600
|
*/
|
|
1538
|
-
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
1601
|
+
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1539
1602
|
/**
|
|
1540
1603
|
* 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
1604
|
*
|
|
1542
1605
|
* @param key - The string key representing the consumer.
|
|
1543
1606
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1544
1607
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1608
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1545
1609
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1546
1610
|
*/
|
|
1547
|
-
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1611
|
+
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1548
1612
|
/**
|
|
1549
1613
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1550
1614
|
*
|
|
1551
1615
|
* @param key - The string key representing the consumer.
|
|
1552
1616
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1553
1617
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1618
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1554
1619
|
* @returns The map with all the Treatment objects
|
|
1555
1620
|
*/
|
|
1556
|
-
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments;
|
|
1621
|
+
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1557
1622
|
/**
|
|
1558
1623
|
* 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
1624
|
*
|
|
1560
1625
|
* @param key - The string key representing the consumer.
|
|
1561
1626
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1562
1627
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1628
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1563
1629
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1564
1630
|
*/
|
|
1565
|
-
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
1631
|
+
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1566
1632
|
/**
|
|
1567
1633
|
* 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
1634
|
*
|
|
1569
1635
|
* @param key - The string key representing the consumer.
|
|
1570
1636
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1571
1637
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1638
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1572
1639
|
* @returns The map with all the Treatment objects
|
|
1573
1640
|
*/
|
|
1574
|
-
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments;
|
|
1641
|
+
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1575
1642
|
/**
|
|
1576
1643
|
* 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
1644
|
*
|
|
1578
1645
|
* @param key - The string key representing the consumer.
|
|
1579
1646
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1580
1647
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1648
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1581
1649
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1582
1650
|
*/
|
|
1583
|
-
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1651
|
+
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1584
1652
|
/**
|
|
1585
1653
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1586
1654
|
*
|
|
@@ -1605,72 +1673,80 @@ declare namespace SplitIO {
|
|
|
1605
1673
|
* @param key - The string key representing the consumer.
|
|
1606
1674
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1607
1675
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1676
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1608
1677
|
* @returns Treatment promise that resolves to the treatment string.
|
|
1609
1678
|
*/
|
|
1610
|
-
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
1679
|
+
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatment;
|
|
1611
1680
|
/**
|
|
1612
1681
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1613
1682
|
*
|
|
1614
1683
|
* @param key - The string key representing the consumer.
|
|
1615
1684
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1616
1685
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1686
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1617
1687
|
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1618
1688
|
*/
|
|
1619
|
-
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
1689
|
+
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentWithConfig;
|
|
1620
1690
|
/**
|
|
1621
1691
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1622
1692
|
*
|
|
1623
1693
|
* @param key - The string key representing the consumer.
|
|
1624
1694
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1625
1695
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1696
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1626
1697
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1627
1698
|
*/
|
|
1628
|
-
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
1699
|
+
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1629
1700
|
/**
|
|
1630
1701
|
* 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
1702
|
*
|
|
1632
1703
|
* @param key - The string key representing the consumer.
|
|
1633
1704
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1634
1705
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1706
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1635
1707
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1636
1708
|
*/
|
|
1637
|
-
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1709
|
+
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1638
1710
|
/**
|
|
1639
1711
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1640
1712
|
*
|
|
1641
1713
|
* @param key - The string key representing the consumer.
|
|
1642
1714
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1643
1715
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1716
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1644
1717
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1645
1718
|
*/
|
|
1646
|
-
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
1719
|
+
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1647
1720
|
/**
|
|
1648
1721
|
* 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
1722
|
*
|
|
1650
1723
|
* @param key - The string key representing the consumer.
|
|
1651
1724
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1652
1725
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1726
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1653
1727
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1654
1728
|
*/
|
|
1655
|
-
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1729
|
+
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1656
1730
|
/**
|
|
1657
1731
|
* 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
1732
|
*
|
|
1659
1733
|
* @param key - The string key representing the consumer.
|
|
1660
1734
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1661
1735
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1736
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1662
1737
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1663
1738
|
*/
|
|
1664
|
-
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
1739
|
+
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1665
1740
|
/**
|
|
1666
1741
|
* 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
1742
|
*
|
|
1668
1743
|
* @param key - The string key representing the consumer.
|
|
1669
1744
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1670
1745
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1746
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1671
1747
|
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1672
1748
|
*/
|
|
1673
|
-
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1749
|
+
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1674
1750
|
/**
|
|
1675
1751
|
* 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
1752
|
*
|
|
@@ -1735,65 +1811,73 @@ declare namespace SplitIO {
|
|
|
1735
1811
|
*
|
|
1736
1812
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1737
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.
|
|
1738
1815
|
* @returns The treatment string.
|
|
1739
1816
|
*/
|
|
1740
|
-
getTreatment(featureFlagName: string, attributes?: Attributes): Treatment;
|
|
1817
|
+
getTreatment(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): Treatment;
|
|
1741
1818
|
/**
|
|
1742
1819
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1743
1820
|
*
|
|
1744
1821
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1745
1822
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1746
|
-
* @
|
|
1823
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1824
|
+
* @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
1825
|
*/
|
|
1748
|
-
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
1826
|
+
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentWithConfig;
|
|
1749
1827
|
/**
|
|
1750
1828
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1751
1829
|
*
|
|
1752
1830
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1753
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.
|
|
1754
1833
|
* @returns The treatments object map.
|
|
1755
1834
|
*/
|
|
1756
|
-
getTreatments(featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
1835
|
+
getTreatments(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1757
1836
|
/**
|
|
1758
1837
|
* 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
1838
|
*
|
|
1760
1839
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1761
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.
|
|
1762
1842
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1763
1843
|
*/
|
|
1764
|
-
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1844
|
+
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1765
1845
|
/**
|
|
1766
1846
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1767
1847
|
*
|
|
1768
1848
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1769
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.
|
|
1770
1851
|
* @returns The map with all the Treatments objects
|
|
1771
1852
|
*/
|
|
1772
|
-
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments;
|
|
1853
|
+
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1773
1854
|
/**
|
|
1774
1855
|
* 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
1856
|
*
|
|
1776
1857
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1777
1858
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1859
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1778
1860
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1779
1861
|
*/
|
|
1780
|
-
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
1862
|
+
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1781
1863
|
/**
|
|
1782
1864
|
* 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
1865
|
*
|
|
1784
1866
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1785
1867
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1868
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1786
1869
|
* @returns The map with all the Treatments objects
|
|
1787
1870
|
*/
|
|
1788
|
-
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments;
|
|
1871
|
+
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): Treatments;
|
|
1789
1872
|
/**
|
|
1790
1873
|
* 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
1874
|
*
|
|
1792
1875
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1793
1876
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1877
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1794
1878
|
* @returns The map with all the TreatmentWithConfig objects
|
|
1795
1879
|
*/
|
|
1796
|
-
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1880
|
+
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): TreatmentsWithConfig;
|
|
1797
1881
|
/**
|
|
1798
1882
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1799
1883
|
*
|
|
@@ -1814,65 +1898,73 @@ declare namespace SplitIO {
|
|
|
1814
1898
|
*
|
|
1815
1899
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1816
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.
|
|
1817
1902
|
* @returns Treatment promise that resolves to the treatment string.
|
|
1818
1903
|
*/
|
|
1819
|
-
getTreatment(featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
1904
|
+
getTreatment(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatment;
|
|
1820
1905
|
/**
|
|
1821
1906
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1822
1907
|
*
|
|
1823
1908
|
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1824
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.
|
|
1825
1911
|
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1826
1912
|
*/
|
|
1827
|
-
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
1913
|
+
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentWithConfig;
|
|
1828
1914
|
/**
|
|
1829
1915
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1830
1916
|
*
|
|
1831
1917
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1832
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.
|
|
1833
1920
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1834
1921
|
*/
|
|
1835
|
-
getTreatments(featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
1922
|
+
getTreatments(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1836
1923
|
/**
|
|
1837
1924
|
* 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
1925
|
*
|
|
1839
1926
|
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1840
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.
|
|
1841
1929
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1842
1930
|
*/
|
|
1843
|
-
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1931
|
+
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1844
1932
|
/**
|
|
1845
1933
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1846
1934
|
*
|
|
1847
1935
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1848
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.
|
|
1849
1938
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1850
1939
|
*/
|
|
1851
|
-
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
1940
|
+
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1852
1941
|
/**
|
|
1853
1942
|
* 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
1943
|
*
|
|
1855
1944
|
* @param flagSet - The flag set name we want to get the treatments.
|
|
1856
1945
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1946
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1857
1947
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1858
1948
|
*/
|
|
1859
|
-
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1949
|
+
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1860
1950
|
/**
|
|
1861
1951
|
* 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
1952
|
*
|
|
1863
1953
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1864
1954
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1955
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1865
1956
|
* @returns Treatments promise that resolves to the treatments object map.
|
|
1866
1957
|
*/
|
|
1867
|
-
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
1958
|
+
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatments;
|
|
1868
1959
|
/**
|
|
1869
1960
|
* 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
1961
|
*
|
|
1871
1962
|
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1872
1963
|
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1964
|
+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
|
|
1873
1965
|
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1874
1966
|
*/
|
|
1875
|
-
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1967
|
+
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes, options?: EvaluationOptions): AsyncTreatmentsWithConfig;
|
|
1876
1968
|
/**
|
|
1877
1969
|
* 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
1970
|
*
|
|
@@ -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;
|