@splitsoftware/splitio-commons 1.10.0 → 1.10.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/cjs/evaluator/index.js +18 -1
  2. package/cjs/logger/constants.js +7 -2
  3. package/cjs/logger/messages/error.js +2 -0
  4. package/cjs/logger/messages/warn.js +4 -1
  5. package/cjs/sdkClient/client.js +33 -0
  6. package/cjs/sdkClient/clientAttributesDecoration.js +20 -0
  7. package/cjs/sdkClient/clientCS.js +4 -0
  8. package/cjs/sdkClient/clientInputValidation.js +52 -3
  9. package/cjs/sdkManager/index.js +1 -0
  10. package/cjs/services/splitApi.js +7 -1
  11. package/cjs/storages/KeyBuilder.js +3 -0
  12. package/cjs/storages/KeyBuilderSS.js +4 -0
  13. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +63 -27
  14. package/cjs/storages/inLocalStorage/index.js +2 -2
  15. package/cjs/storages/inMemory/InMemoryStorage.js +2 -2
  16. package/cjs/storages/inMemory/InMemoryStorageCS.js +3 -3
  17. package/cjs/storages/inMemory/SplitsCacheInMemory.js +47 -2
  18. package/cjs/storages/inRedis/SplitsCacheInRedis.js +11 -0
  19. package/cjs/storages/pluggable/SplitsCachePluggable.js +11 -0
  20. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
  21. package/cjs/sync/polling/updaters/splitChangesUpdater.js +24 -4
  22. package/cjs/sync/submitters/telemetrySubmitter.js +15 -1
  23. package/cjs/utils/constants/index.js +6 -2
  24. package/cjs/utils/lang/sets.js +9 -1
  25. package/cjs/utils/settingsValidation/index.js +1 -1
  26. package/cjs/utils/settingsValidation/splitFilters.js +78 -15
  27. package/esm/evaluator/index.js +16 -0
  28. package/esm/logger/constants.js +5 -0
  29. package/esm/logger/messages/error.js +2 -0
  30. package/esm/logger/messages/warn.js +4 -1
  31. package/esm/sdkClient/client.js +35 -2
  32. package/esm/sdkClient/clientAttributesDecoration.js +20 -0
  33. package/esm/sdkClient/clientCS.js +4 -0
  34. package/esm/sdkClient/clientInputValidation.js +52 -3
  35. package/esm/sdkManager/index.js +1 -0
  36. package/esm/services/splitApi.js +7 -1
  37. package/esm/storages/KeyBuilder.js +3 -0
  38. package/esm/storages/KeyBuilderSS.js +4 -0
  39. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +63 -27
  40. package/esm/storages/inLocalStorage/index.js +2 -2
  41. package/esm/storages/inMemory/InMemoryStorage.js +2 -2
  42. package/esm/storages/inMemory/InMemoryStorageCS.js +3 -3
  43. package/esm/storages/inMemory/SplitsCacheInMemory.js +47 -2
  44. package/esm/storages/inRedis/SplitsCacheInRedis.js +11 -0
  45. package/esm/storages/pluggable/SplitsCachePluggable.js +11 -0
  46. package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
  47. package/esm/sync/polling/updaters/splitChangesUpdater.js +24 -4
  48. package/esm/sync/submitters/telemetrySubmitter.js +15 -1
  49. package/esm/utils/constants/index.js +4 -0
  50. package/esm/utils/lang/sets.js +7 -0
  51. package/esm/utils/settingsValidation/index.js +1 -1
  52. package/esm/utils/settingsValidation/splitFilters.js +72 -10
  53. package/package.json +2 -2
  54. package/src/dtos/types.ts +3 -2
  55. package/src/evaluator/index.ts +24 -0
  56. package/src/logger/constants.ts +5 -0
  57. package/src/logger/messages/error.ts +2 -0
  58. package/src/logger/messages/warn.ts +4 -1
  59. package/src/sdkClient/client.ts +42 -2
  60. package/src/sdkClient/clientAttributesDecoration.ts +24 -0
  61. package/src/sdkClient/clientCS.ts +4 -0
  62. package/src/sdkClient/clientInputValidation.ts +56 -3
  63. package/src/sdkManager/index.ts +1 -0
  64. package/src/services/splitApi.ts +6 -1
  65. package/src/storages/AbstractSplitsCacheAsync.ts +2 -0
  66. package/src/storages/AbstractSplitsCacheSync.ts +3 -0
  67. package/src/storages/KeyBuilder.ts +4 -0
  68. package/src/storages/KeyBuilderSS.ts +4 -0
  69. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +74 -28
  70. package/src/storages/inLocalStorage/index.ts +2 -2
  71. package/src/storages/inMemory/InMemoryStorage.ts +2 -2
  72. package/src/storages/inMemory/InMemoryStorageCS.ts +3 -3
  73. package/src/storages/inMemory/SplitsCacheInMemory.ts +50 -1
  74. package/src/storages/inRedis/SplitsCacheInRedis.ts +12 -0
  75. package/src/storages/pluggable/SplitsCachePluggable.ts +12 -0
  76. package/src/storages/types.ts +7 -3
  77. package/src/sync/polling/syncTasks/splitsSyncTask.ts +1 -0
  78. package/src/sync/polling/updaters/splitChangesUpdater.ts +27 -4
  79. package/src/sync/submitters/telemetrySubmitter.ts +19 -2
  80. package/src/sync/submitters/types.ts +7 -1
  81. package/src/types.ts +114 -1
  82. package/src/utils/constants/index.ts +4 -0
  83. package/src/utils/lang/sets.ts +8 -0
  84. package/src/utils/settingsValidation/index.ts +1 -1
  85. package/src/utils/settingsValidation/splitFilters.ts +78 -10
  86. package/types/dtos/types.d.ts +1 -0
  87. package/types/evaluator/index.d.ts +1 -0
  88. package/types/logger/constants.d.ts +5 -0
  89. package/types/myLogger.d.ts +5 -0
  90. package/types/sdkClient/clientAttributesDecoration.d.ts +4 -0
  91. package/types/sdkClient/types.d.ts +18 -0
  92. package/types/storages/AbstractSplitsCacheAsync.d.ts +2 -0
  93. package/types/storages/AbstractSplitsCacheSync.d.ts +2 -0
  94. package/types/storages/KeyBuilder.d.ts +1 -0
  95. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +6 -1
  96. package/types/storages/inMemory/CountsCacheInMemory.d.ts +20 -0
  97. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +20 -0
  98. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +9 -1
  99. package/types/storages/inRedis/CountsCacheInRedis.d.ts +9 -0
  100. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +9 -0
  101. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +8 -0
  102. package/types/storages/metadataBuilder.d.ts +3 -0
  103. package/types/storages/pluggable/SplitsCachePluggable.d.ts +8 -0
  104. package/types/storages/types.d.ts +4 -0
  105. package/types/sync/offline/LocalhostFromFile.d.ts +2 -0
  106. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -0
  107. package/types/sync/offline/updaters/splitChangesUpdater.d.ts +0 -0
  108. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +3 -3
  109. package/types/sync/submitters/eventsSyncTask.d.ts +8 -0
  110. package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +5 -0
  111. package/types/sync/submitters/impressionCountsSyncTask.d.ts +13 -0
  112. package/types/sync/submitters/impressionsSyncTask.d.ts +14 -0
  113. package/types/sync/submitters/metricsSyncTask.d.ts +12 -0
  114. package/types/sync/submitters/submitterSyncTask.d.ts +10 -0
  115. package/types/sync/submitters/types.d.ts +7 -1
  116. package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +5 -0
  117. package/types/sync/syncTaskComposite.d.ts +5 -0
  118. package/types/trackers/filter/bloomFilter.d.ts +10 -0
  119. package/types/trackers/filter/dictionaryFilter.d.ts +8 -0
  120. package/types/trackers/filter/types.d.ts +5 -0
  121. package/types/types.d.ts +114 -1
  122. package/types/utils/constants/index.d.ts +4 -0
  123. package/types/utils/lang/sets.d.ts +1 -0
  124. package/types/utils/settingsValidation/splitFilters.d.ts +2 -2
  125. package/types/utils/timeTracker/index.d.ts +70 -0
  126. package/types/sdkClient/identity.d.ts +0 -6
  127. package/types/utils/inputValidation/sdkKey.d.ts +0 -7
  128. /package/types/storages/inMemory/{UniqueKeysCacheInMemory.d.ts → uniqueKeysCacheInMemory.d.ts} +0 -0
  129. /package/types/storages/inMemory/{UniqueKeysCacheInMemoryCS.d.ts → uniqueKeysCacheInMemoryCS.d.ts} +0 -0
  130. /package/types/storages/inRedis/{UniqueKeysCacheInRedis.d.ts → uniqueKeysCacheInRedis.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ import { SplitIO } from '../../types';
2
+ export declare function LocalhostFromFile(): SplitIO.LocalhostFactory;
@@ -0,0 +1,2 @@
1
+ import { ISplitsParser } from './types';
2
+ export declare function splitsParserFromFileFactory(): ISplitsParser;
@@ -1,7 +1,7 @@
1
1
  import { ISet } from '../../../utils/lang/sets';
2
2
  import { ISegmentsCacheBase, ISplitsCacheBase } from '../../../storages/types';
3
3
  import { ISplitChangesFetcher } from '../fetchers/types';
4
- import { ISplit } from '../../../dtos/types';
4
+ import { ISplit, ISplitFiltersValidation } from '../../../dtos/types';
5
5
  import { ISplitsEventEmitter } from '../../../readiness/types';
6
6
  import { ILogger } from '../../../logger/types';
7
7
  declare type ISplitChangesUpdater = (noCache?: boolean, till?: number, splitUpdateNotification?: {
@@ -23,7 +23,7 @@ interface ISplitMutations {
23
23
  * i.e., an object with added splits, removed splits and used segments.
24
24
  * Exported for testing purposes.
25
25
  */
26
- export declare function computeSplitsMutation(entries: ISplit[]): ISplitMutations;
26
+ export declare function computeSplitsMutation(entries: ISplit[], filters: ISplitFiltersValidation): ISplitMutations;
27
27
  /**
28
28
  * factory of SplitChanges updater, a task that:
29
29
  * - fetches split changes using `splitChangesFetcher`
@@ -38,5 +38,5 @@ export declare function computeSplitsMutation(entries: ISplit[]): ISplitMutation
38
38
  * @param requestTimeoutBeforeReady How long the updater will wait for the request to timeout. Default 0, i.e., never timeout.
39
39
  * @param retriesOnFailureBeforeReady How many retries on `/splitChanges` we the updater do in case of failure or timeout. Default 0, i.e., no retries.
40
40
  */
41
- export declare function splitChangesUpdaterFactory(log: ILogger, splitChangesFetcher: ISplitChangesFetcher, splits: ISplitsCacheBase, segments: ISegmentsCacheBase, splitsEventEmitter?: ISplitsEventEmitter, requestTimeoutBeforeReady?: number, retriesOnFailureBeforeReady?: number, isClientSide?: boolean): ISplitChangesUpdater;
41
+ export declare function splitChangesUpdaterFactory(log: ILogger, splitChangesFetcher: ISplitChangesFetcher, splits: ISplitsCacheBase, segments: ISegmentsCacheBase, splitFiltersValidation: ISplitFiltersValidation, splitsEventEmitter?: ISplitsEventEmitter, requestTimeoutBeforeReady?: number, retriesOnFailureBeforeReady?: number, isClientSide?: boolean): ISplitChangesUpdater;
42
42
  export {};
@@ -0,0 +1,8 @@
1
+ import { IEventsCacheSync } from '../../storages/types';
2
+ import { IPostEventsBulk } from '../../services/types';
3
+ import { ISyncTask, ITimeTracker } from '../types';
4
+ import { ILogger } from '../../logger/types';
5
+ /**
6
+ * Sync task that periodically posts tracked events
7
+ */
8
+ export declare function eventsSyncTaskFactory(log: ILogger, postEventsBulk: IPostEventsBulk, eventsCache: IEventsCacheSync, eventsPushRate: number, eventsFirstPushWindow: number, latencyTracker?: ITimeTracker): ISyncTask;
@@ -0,0 +1,5 @@
1
+ import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
+ /**
3
+ * Submitter that periodically posts impression counts
4
+ */
5
+ export declare function impressionCountsSubmitterInRedisFactory(params: ISdkFactoryContextSync): import("../types").ISyncTask<[], void>;
@@ -0,0 +1,13 @@
1
+ import { ISyncTask, ITimeTracker } from '../types';
2
+ import { IPostTestImpressionsCount } from '../../services/types';
3
+ import { IImpressionCountsCacheSync } from '../../storages/types';
4
+ import { ImpressionCountsPayload } from './types';
5
+ import { ILogger } from '../../logger/types';
6
+ /**
7
+ * Converts `impressionCounts` data from cache into request payload.
8
+ */
9
+ export declare function fromImpressionCountsCollector(impressionsCount: Record<string, number>): ImpressionCountsPayload;
10
+ /**
11
+ * Sync task that periodically posts impression counts
12
+ */
13
+ export declare function impressionCountsSyncTaskFactory(log: ILogger, postTestImpressionsCount: IPostTestImpressionsCount, impressionCountsCache: IImpressionCountsCacheSync, latencyTracker?: ITimeTracker): ISyncTask;
@@ -0,0 +1,14 @@
1
+ import { ISyncTask, ITimeTracker } from '../types';
2
+ import { IPostTestImpressionsBulk } from '../../services/types';
3
+ import { IImpressionsCacheSync } from '../../storages/types';
4
+ import { ImpressionDTO } from '../../types';
5
+ import { ImpressionsPayload } from './types';
6
+ import { ILogger } from '../../logger/types';
7
+ /**
8
+ * Converts `impressions` data from cache into request payload.
9
+ */
10
+ export declare function fromImpressionsCollector(sendLabels: boolean, data: ImpressionDTO[]): ImpressionsPayload;
11
+ /**
12
+ * Sync task that periodically posts impressions data
13
+ */
14
+ export declare function impressionsSyncTaskFactory(log: ILogger, postTestImpressionsBulk: IPostTestImpressionsBulk, impressionsCache: IImpressionsCacheSync, impressionsRefreshRate: number, sendLabels?: boolean, latencyTracker?: ITimeTracker): ISyncTask;
@@ -0,0 +1,12 @@
1
+ import { ICountsCacheSync, ILatenciesCacheSync } from '../../storages/types';
2
+ import { IPostMetricsCounters, IPostMetricsTimes } from '../../services/types';
3
+ import { ISyncTask, ITimeTracker } from '../types';
4
+ import { ILogger } from '../../logger/types';
5
+ /**
6
+ * Sync task that periodically posts telemetry counts
7
+ */
8
+ export declare function countsSyncTaskFactory(log: ILogger, postMetricsCounters: IPostMetricsCounters, countsCache: ICountsCacheSync, metricsRefreshRate: number, latencyTracker?: ITimeTracker): ISyncTask;
9
+ /**
10
+ * Sync task that periodically posts telemetry latencies
11
+ */
12
+ export declare function latenciesSyncTaskFactory(log: ILogger, postMetricsLatencies: IPostMetricsTimes, latenciesCache: ILatenciesCacheSync, metricsRefreshRate: number, latencyTracker?: ITimeTracker): ISyncTask;
@@ -0,0 +1,10 @@
1
+ import { ISyncTask, ITimeTracker } from '../types';
2
+ import { IRecorderCacheProducerSync } from '../../storages/types';
3
+ import { ILogger } from '../../logger/types';
4
+ import { IResponse } from '../../services/types';
5
+ /**
6
+ * Base function to create submitter sync tasks, such as ImpressionsSyncTask and EventsSyncTask
7
+ */
8
+ export declare function submitterSyncTaskFactory<TState extends {
9
+ length?: number;
10
+ }>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache: IRecorderCacheProducerSync<TState>, postRate: number, dataName: string, latencyTracker?: ITimeTracker, fromCacheToPayload?: (cacheData: TState) => any, maxRetries?: number, debugLogs?: boolean): ISyncTask<[], void>;
@@ -110,7 +110,11 @@ export declare type TREATMENTS = 'ts';
110
110
  export declare type TREATMENT_WITH_CONFIG = 'tc';
111
111
  export declare type TREATMENTS_WITH_CONFIG = 'tcs';
112
112
  export declare type TRACK = 'tr';
113
- export declare type Method = TREATMENT | TREATMENTS | TREATMENT_WITH_CONFIG | TREATMENTS_WITH_CONFIG | TRACK;
113
+ export declare type TREATMENTS_BY_FLAGSET = 'tf';
114
+ export declare type TREATMENTS_BY_FLAGSETS = 'tfs';
115
+ export declare type TREATMENTS_WITH_CONFIG_BY_FLAGSET = 'tcf';
116
+ export declare type TREATMENTS_WITH_CONFIG_BY_FLAGSETS = 'tcfs';
117
+ export declare type Method = TREATMENT | TREATMENTS | TREATMENT_WITH_CONFIG | TREATMENTS_WITH_CONFIG | TRACK | TREATMENTS_BY_FLAGSET | TREATMENTS_BY_FLAGSETS | TREATMENTS_WITH_CONFIG_BY_FLAGSET | TREATMENTS_WITH_CONFIG_BY_FLAGSETS;
114
118
  export declare type MethodLatencies = Partial<Record<Method, Array<number>>>;
115
119
  export declare type MethodExceptions = Partial<Record<Method, number>>;
116
120
  export declare type CONNECTION_ESTABLISHED = 0;
@@ -201,6 +205,8 @@ export declare type TelemetryConfigStatsPayload = TelemetryConfigStats & {
201
205
  nR: number;
202
206
  i?: Array<string>;
203
207
  uC: number;
208
+ fsT: number;
209
+ fsI: number;
204
210
  };
205
211
  export interface ISubmitterManager extends ISyncTask {
206
212
  start(onlyTelemetry?: boolean): void;
@@ -0,0 +1,5 @@
1
+ import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
+ /**
3
+ * Submitter that periodically posts impression counts
4
+ */
5
+ export declare function uniqueKeysSubmitterInRedisFactory(params: ISdkFactoryContextSync): import("../types").ISyncTask<[], void>;
@@ -0,0 +1,5 @@
1
+ import { ISyncTask } from './types';
2
+ /**
3
+ * Composite Sync Task: group of sync tasks that are treated as a single one.
4
+ */
5
+ export declare function syncTaskComposite(syncTasks: ISyncTask[]): ISyncTask;
@@ -0,0 +1,10 @@
1
+ import { IFilter } from './types';
2
+ export declare class BloomFilterImp implements IFilter {
3
+ private spectedInsertions;
4
+ private errorRate;
5
+ private filter;
6
+ constructor(spectedInsertions: number, errorRate: number);
7
+ add(data: string): boolean;
8
+ contains(data: string): boolean;
9
+ clear(): void;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { IFilter } from './types';
2
+ export declare class DictionaryFilter implements IFilter {
3
+ private filter;
4
+ constructor();
5
+ add(data: string): boolean;
6
+ contains(data: string): boolean;
7
+ clear(): void;
8
+ }
@@ -0,0 +1,5 @@
1
+ export interface IFilter {
2
+ add(data: string): boolean;
3
+ contains(data: string): boolean;
4
+ clear(): void;
5
+ }
package/types/types.d.ts CHANGED
@@ -601,6 +601,11 @@ export declare namespace SplitIO {
601
601
  configs: {
602
602
  [treatmentName: string]: string;
603
603
  };
604
+ /**
605
+ * list of sets per feature flag
606
+ * @property {string[]} sets
607
+ */
608
+ sets?: string[];
604
609
  /**
605
610
  * The default treatment of the feature flag.
606
611
  * @property {string} defaultTreatment
@@ -711,7 +716,7 @@ export declare namespace SplitIO {
711
716
  * SplitFilter type.
712
717
  * @typedef {string} SplitFilterType
713
718
  */
714
- type SplitFilterType = 'byName' | 'byPrefix';
719
+ type SplitFilterType = 'byName' | 'byPrefix' | 'bySet';
715
720
  /**
716
721
  * Defines a feature flag filter, described by a type and list of values.
717
722
  */
@@ -1061,6 +1066,42 @@ export declare namespace SplitIO {
1061
1066
  * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1062
1067
  */
1063
1068
  getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
1069
+ /**
1070
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flagSet.
1071
+ * @function getTreatmentsByFlagSet
1072
+ * @param {string} key - The string key representing the consumer.
1073
+ * @param {string} flagSet - The flagSet name we want to get the treatments.
1074
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1075
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1076
+ */
1077
+ getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments;
1078
+ /**
1079
+ * 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 flagSets.
1080
+ * @function getTreatmentsWithConfigByFlagSet
1081
+ * @param {string} key - The string key representing the consumer.
1082
+ * @param {string} flagSet - The flagSet name we want to get the treatments.
1083
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1084
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1085
+ */
1086
+ getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
1087
+ /**
1088
+ * 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 flagSets.
1089
+ * @function getTreatmentsByFlagSets
1090
+ * @param {string} key - The string key representing the consumer.
1091
+ * @param {Array<string>} flagSets - An array of the flagSet names we want to get the treatments.
1092
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1093
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1094
+ */
1095
+ getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments;
1096
+ /**
1097
+ * 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 flagSets.
1098
+ * @function getTreatmentsWithConfigByFlagSets
1099
+ * @param {string} key - The string key representing the consumer.
1100
+ * @param {Array<string>} flagSets - An array of the flagSet names we want to get the treatments.
1101
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1102
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1103
+ */
1104
+ getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
1064
1105
  /**
1065
1106
  * Tracks an event to be fed to the results product on Split user interface.
1066
1107
  * @function track
@@ -1121,6 +1162,46 @@ export declare namespace SplitIO {
1121
1162
  * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
1122
1163
  */
1123
1164
  getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
1165
+ /**
1166
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the features related to the given flag set.
1167
+ * For usage on NodeJS as we don't have only one key.
1168
+ * @function getTreatmentsByFlagSet
1169
+ * @param {string} key - The string key representing the consumer.
1170
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1171
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1172
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1173
+ */
1174
+ getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments;
1175
+ /**
1176
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for features related to the given flag set.
1177
+ * For usage on NodeJS as we don't have only one key.
1178
+ * @function getTreatmentsWithConfigByFlagSet
1179
+ * @param {string} key - The string key representing the consumer.
1180
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1181
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1182
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1183
+ */
1184
+ getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
1185
+ /**
1186
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the feature flags related to the given flag sets.
1187
+ * For usage on NodeJS as we don't have only one key.
1188
+ * @function getTreatmentsByFlagSets
1189
+ * @param {string} key - The string key representing the consumer.
1190
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1191
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1192
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1193
+ */
1194
+ getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments;
1195
+ /**
1196
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the feature flags related to the given flag sets.
1197
+ * For usage on NodeJS as we don't have only one key.
1198
+ * @function getTreatmentsWithConfigByFlagSets
1199
+ * @param {string} key - The string key representing the consumer.
1200
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1201
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1202
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1203
+ */
1204
+ getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
1124
1205
  /**
1125
1206
  * 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).
1126
1207
  * @function track
@@ -1171,6 +1252,38 @@ export declare namespace SplitIO {
1171
1252
  * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1172
1253
  */
1173
1254
  getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
1255
+ /**
1256
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
1257
+ * @function getTreatmentsByFlagSet
1258
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1259
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1260
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1261
+ */
1262
+ getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments;
1263
+ /**
1264
+ * 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.
1265
+ * @function getTreatmentsWithConfigByFlagSet
1266
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1267
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1268
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1269
+ */
1270
+ getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
1271
+ /**
1272
+ * 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.
1273
+ * @function getTreatmentsByFlagSets
1274
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1275
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1276
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1277
+ */
1278
+ getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments;
1279
+ /**
1280
+ * 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.
1281
+ * @function getTreatmentsWithConfigByFlagSets
1282
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1283
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1284
+ * @returns {Treatments} The map with all the TreatmentWithConfig objects
1285
+ */
1286
+ getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
1174
1287
  /**
1175
1288
  * Tracks an event to be fed to the results product on Split user interface.
1176
1289
  * @function track
@@ -45,6 +45,10 @@ export declare const TREATMENT = "t";
45
45
  export declare const TREATMENTS = "ts";
46
46
  export declare const TREATMENT_WITH_CONFIG = "tc";
47
47
  export declare const TREATMENTS_WITH_CONFIG = "tcs";
48
+ export declare const TREATMENTS_BY_FLAGSET = "tf";
49
+ export declare const TREATMENTS_BY_FLAGSETS = "tfs";
50
+ export declare const TREATMENTS_WITH_CONFIG_BY_FLAGSET = "tcf";
51
+ export declare const TREATMENTS_WITH_CONFIG_BY_FLAGSETS = "tcfs";
48
52
  export declare const TRACK = "tr";
49
53
  export declare const CONNECTION_ESTABLISHED = 0;
50
54
  export declare const OCCUPANCY_PRI = 10;
@@ -57,4 +57,5 @@ interface ISetConstructor {
57
57
  */
58
58
  export declare function __getSetConstructor(): ISetConstructor;
59
59
  export declare const _Set: ISetConstructor;
60
+ export declare function returnSetsUnion<T>(set: ISet<T>, set2: ISet<T>): ISet<T>;
60
61
  export {};
@@ -5,7 +5,6 @@ import { ILogger } from '../../logger/types';
5
5
  *
6
6
  * @param {ILogger} log logger
7
7
  * @param {any} maybeSplitFilters split filters configuration param provided by the user
8
- * @param {string} mode settings mode
9
8
  * @returns it returns an object with the following properties:
10
9
  * - `validFilters`: the validated `splitFilters` configuration object defined by the user.
11
10
  * - `queryString`: the parsed split filter query. it is null if all filters are invalid or all values in filters are invalid.
@@ -13,4 +12,5 @@ import { ILogger } from '../../logger/types';
13
12
  *
14
13
  * @throws Error if the some of the grouped list of values per filter exceeds the max allowed length
15
14
  */
16
- export declare function validateSplitFilters(log: ILogger, maybeSplitFilters: any, mode: string): ISplitFiltersValidation;
15
+ export declare function validateSplitFilters(log: ILogger, maybeSplitFilters: any): ISplitFiltersValidation;
16
+ export declare function flagSetsAreValid(log: ILogger, method: string, flagSets: string[], flagSetsInConfig: string[]): string[];
@@ -0,0 +1,70 @@
1
+ import { ILogger } from '../../logger/types';
2
+ import { IResponse } from '../../services/types';
3
+ interface MetricsCollector {
4
+ countException(): void;
5
+ count(status: number): void;
6
+ latency(ms: number): void;
7
+ ready(ms: number): void;
8
+ getTreatment(ms: number): void;
9
+ getTreatments(ms: number): void;
10
+ getTreatmentWithConfig(ms: number): void;
11
+ getTreatmentsWithConfig(ms: number): void;
12
+ [method: string]: (ms: number) => void;
13
+ }
14
+ export declare const TrackerAPI: {
15
+ /**
16
+ * "Private" method, used to attach count/countException and stop callbacks to a promise.
17
+ *
18
+ * @param {ILogger} log - Logger.
19
+ * @param {Promise} promise - The promise we want to attach the callbacks.
20
+ * @param {string} task - The name of the task.
21
+ * @param {number | string} modifier - (optional) The modifier for the task, if any.
22
+ */
23
+ __attachToPromise(log: ILogger, promise: Promise<IResponse>, task: string, collector: false | MetricsCollector, modifier?: string | number | undefined): Promise<IResponse>;
24
+ /**
25
+ * Starts tracking the time for a given task. All tasks tracked are considered "unique" because
26
+ * there may be multiple SDK instances tracking a "generic" task, making any task non-generic.
27
+ *
28
+ * @param {ILogger} log - Logger.
29
+ * @param {string} task - The task we are starting.
30
+ * @param {Object} collectors - The collectors map.
31
+ * @param {Promise} promise - (optional) The promise we are tracking.
32
+ * @return {Function | Promise} The stop function for this specific task or the promise received with the callbacks registered.
33
+ */
34
+ start(log: ILogger, task: string, collectors?: Record<string, MetricsCollector> | undefined, promise?: Promise<IResponse> | undefined, now?: (() => number) | undefined): Promise<IResponse> | (() => number);
35
+ /**
36
+ * Setup the collector for a task that reports metrics.
37
+ *
38
+ * @param {string} task - The task name
39
+ * @param {number | string} taskUniqueId - The unique identifier for this task
40
+ * @param {Object} collectors - The collectors map.
41
+ */
42
+ setCollectorForTask(task: string, taskUniqueId: number | string, collectors: Record<string, MetricsCollector>): void;
43
+ /**
44
+ * Stops the tracking of a given task.
45
+ *
46
+ * @param {ILogger} log - Logger.
47
+ * @param {string} task - The task we are starting.
48
+ * @param {number | string} modifier - (optional) The modifier for that specific task.
49
+ */
50
+ stop(log: ILogger, task: string, modifier?: string | number | undefined): number | undefined;
51
+ /**
52
+ * The constants shortcut for the task names.
53
+ */
54
+ TaskNames: {
55
+ SDK_READY: string;
56
+ SDK_GET_TREATMENT: string;
57
+ SDK_GET_TREATMENTS: string;
58
+ SDK_GET_TREATMENT_WITH_CONFIG: string;
59
+ SDK_GET_TREATMENTS_WITH_CONFIG: string;
60
+ SPLITS_READY: string;
61
+ SEGMENTS_READY: string;
62
+ METRICS_PUSH: string;
63
+ IMPRESSIONS_PUSH: string;
64
+ EVENTS_PUSH: string;
65
+ MY_SEGMENTS_FETCH: string;
66
+ SEGMENTS_FETCH: string;
67
+ SPLITS_FETCH: string;
68
+ };
69
+ };
70
+ export {};
@@ -1,6 +0,0 @@
1
- import { SplitIO } from '../types';
2
- export declare function buildInstanceId(key: SplitIO.SplitKey, trafficType?: string): string;
3
- export declare function parseInstanceId(instanceId: string): {
4
- key: SplitIO.SplitKey;
5
- trafficType?: string;
6
- };
@@ -1,7 +0,0 @@
1
- import { ILogger } from '../../logger/types';
2
- /** validates the given SDK key */
3
- export declare function validateApiKey(log: ILogger, maybeSdkKey: any): string | false;
4
- export declare const usedKeysMap: Record<string, number>;
5
- /** validates the given SDK key and also warns if it is in use */
6
- export declare function validateAndTrackApiKey(log: ILogger, maybeSdkKey: any): string | false;
7
- export declare function releaseApiKey(sdkKey: string): void;