@splitsoftware/splitio-commons 1.12.1-rc.1 → 1.12.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.
Files changed (53) hide show
  1. package/CHANGES.txt +2 -1
  2. package/cjs/sdkClient/client.js +4 -4
  3. package/cjs/sdkManager/index.js +2 -2
  4. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -3
  5. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +1 -5
  6. package/cjs/storages/inRedis/RedisAdapter.js +12 -10
  7. package/cjs/storages/inRedis/SplitsCacheInRedis.js +14 -10
  8. package/cjs/storages/pluggable/SplitsCachePluggable.js +5 -5
  9. package/cjs/utils/inputValidation/index.js +5 -5
  10. package/cjs/utils/inputValidation/{splitExistance.js → splitExistence.js} +3 -3
  11. package/cjs/utils/inputValidation/{trafficTypeExistance.js → trafficTypeExistence.js} +6 -6
  12. package/cjs/utils/redis/RedisMock.js +1 -7
  13. package/esm/sdkClient/client.js +4 -4
  14. package/esm/sdkManager/index.js +3 -3
  15. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -3
  16. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +1 -5
  17. package/esm/storages/inRedis/RedisAdapter.js +12 -10
  18. package/esm/storages/inRedis/SplitsCacheInRedis.js +14 -10
  19. package/esm/storages/pluggable/SplitsCachePluggable.js +5 -5
  20. package/esm/utils/inputValidation/index.js +2 -2
  21. package/esm/utils/inputValidation/{splitExistance.js → splitExistence.js} +1 -1
  22. package/esm/utils/inputValidation/{trafficTypeExistance.js → trafficTypeExistence.js} +4 -4
  23. package/esm/utils/redis/RedisMock.js +1 -7
  24. package/package.json +1 -1
  25. package/src/sdkClient/client.ts +4 -4
  26. package/src/sdkManager/index.ts +3 -3
  27. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +4 -5
  28. package/src/storages/inRedis/EventsCacheInRedis.ts +3 -3
  29. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +4 -8
  30. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +3 -3
  31. package/src/storages/inRedis/RedisAdapter.ts +16 -12
  32. package/src/storages/inRedis/SegmentsCacheInRedis.ts +3 -3
  33. package/src/storages/inRedis/SplitsCacheInRedis.ts +17 -14
  34. package/src/storages/inRedis/TelemetryCacheInRedis.ts +2 -2
  35. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +3 -3
  36. package/src/storages/pluggable/SplitsCachePluggable.ts +5 -5
  37. package/src/utils/inputValidation/index.ts +2 -2
  38. package/src/utils/inputValidation/{splitExistance.ts → splitExistence.ts} +1 -1
  39. package/src/utils/inputValidation/{trafficTypeExistance.ts → trafficTypeExistence.ts} +4 -4
  40. package/src/utils/redis/RedisMock.ts +1 -11
  41. package/types/storages/inRedis/EventsCacheInRedis.d.ts +2 -2
  42. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +3 -2
  43. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +2 -2
  44. package/types/storages/inRedis/RedisAdapter.d.ts +3 -2
  45. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +2 -2
  46. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +5 -5
  47. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +2 -2
  48. package/types/storages/inRedis/UniqueKeysCacheInRedis.d.ts +3 -2
  49. package/types/storages/pluggable/SplitsCachePluggable.d.ts +4 -4
  50. package/types/utils/inputValidation/index.d.ts +2 -2
  51. package/types/utils/inputValidation/splitExistence.d.ts +7 -0
  52. package/types/utils/inputValidation/trafficTypeExistence.d.ts +9 -0
  53. package/types/utils/redis/RedisMock.d.ts +0 -1
@@ -1,15 +1,15 @@
1
1
  import { IImpressionsCacheAsync } from '../types';
2
2
  import { IMetadata } from '../../dtos/types';
3
3
  import { ImpressionDTO } from '../../types';
4
- import { Redis } from 'ioredis';
5
4
  import { StoredImpressionWithMetadata } from '../../sync/submitters/types';
6
5
  import { ILogger } from '../../logger/types';
6
+ import type { RedisAdapter } from './RedisAdapter';
7
7
  export declare class ImpressionsCacheInRedis implements IImpressionsCacheAsync {
8
8
  private readonly log;
9
9
  private readonly key;
10
10
  private readonly redis;
11
11
  private readonly metadata;
12
- constructor(log: ILogger, key: string, redis: Redis, metadata: IMetadata);
12
+ constructor(log: ILogger, key: string, redis: RedisAdapter, metadata: IMetadata);
13
13
  track(impressions: ImpressionDTO[]): Promise<void>;
14
14
  count(): Promise<number>;
15
15
  drop(count?: number): Promise<any>;
@@ -8,7 +8,8 @@ export declare class RedisAdapter extends ioredis {
8
8
  private _options;
9
9
  private _notReadyCommandsQueue?;
10
10
  private _runningCommands;
11
- constructor(log: ILogger, storageSettings: Record<string, any>);
11
+ constructor(log: ILogger, storageSettings?: Record<string, any>);
12
+ pipelineExec(commands?: (string | number)[][]): Promise<Array<[Error | null, any]>>;
12
13
  _listenToEvents(): void;
13
14
  _setTimeoutWrappers(): void;
14
15
  _setDisconnectWrapper(): void;
@@ -20,5 +21,5 @@ export declare class RedisAdapter extends ioredis {
20
21
  /**
21
22
  * Parses the options into what we care about.
22
23
  */
23
- static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>): object;
24
+ static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }?: Record<string, any>): object;
24
25
  }
@@ -1,12 +1,12 @@
1
- import { Redis } from 'ioredis';
2
1
  import { ILogger } from '../../logger/types';
3
2
  import { KeyBuilderSS } from '../KeyBuilderSS';
4
3
  import { ISegmentsCacheAsync } from '../types';
4
+ import type { RedisAdapter } from './RedisAdapter';
5
5
  export declare class SegmentsCacheInRedis implements ISegmentsCacheAsync {
6
6
  private readonly log;
7
7
  private readonly redis;
8
8
  private readonly keys;
9
- constructor(log: ILogger, keys: KeyBuilderSS, redis: Redis);
9
+ constructor(log: ILogger, keys: KeyBuilderSS, redis: RedisAdapter);
10
10
  addToSegment(name: string, segmentKeys: string[]): Promise<boolean>;
11
11
  removeFromSegment(name: string, segmentKeys: string[]): Promise<boolean>;
12
12
  isInSegment(name: string, key: string): Promise<boolean>;
@@ -1,9 +1,9 @@
1
1
  import { KeyBuilderSS } from '../KeyBuilderSS';
2
- import { Redis } from 'ioredis';
3
2
  import { ILogger } from '../../logger/types';
4
3
  import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
5
4
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
6
5
  import { ISet } from '../../utils/lang/sets';
6
+ import type { RedisAdapter } from './RedisAdapter';
7
7
  /**
8
8
  * ISplitsCacheAsync implementation that stores split definitions in Redis.
9
9
  * Supported by Node.
@@ -14,7 +14,7 @@ export declare class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
14
14
  private readonly keys;
15
15
  private redisError?;
16
16
  private readonly flagSetsFilter;
17
- constructor(log: ILogger, keys: KeyBuilderSS, redis: Redis, splitFiltersValidation?: ISplitFiltersValidation);
17
+ constructor(log: ILogger, keys: KeyBuilderSS, redis: RedisAdapter, splitFiltersValidation?: ISplitFiltersValidation);
18
18
  private _decrementCounts;
19
19
  private _incrementCounts;
20
20
  private _updateFlagSets;
@@ -75,9 +75,9 @@ export declare class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
75
75
  */
76
76
  getSplitNames(): Promise<string[]>;
77
77
  /**
78
- * Get list of split names related to a given flag set names list.
79
- * The returned promise is resolved with the list of split names,
80
- * or rejected if any wrapper operation fails.
78
+ * Get list of feature flag names related to a given list of flag set names.
79
+ * The returned promise is resolved with the list of feature flag names per flag set,
80
+ * or rejected if the pipelined redis operation fails.
81
81
  */
82
82
  getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
83
83
  /**
@@ -2,7 +2,7 @@ import { ILogger } from '../../logger/types';
2
2
  import { Method, MultiConfigs, MultiMethodExceptions, MultiMethodLatencies } from '../../sync/submitters/types';
3
3
  import { KeyBuilderSS } from '../KeyBuilderSS';
4
4
  import { ITelemetryCacheAsync } from '../types';
5
- import { Redis } from 'ioredis';
5
+ import type { RedisAdapter } from './RedisAdapter';
6
6
  export declare class TelemetryCacheInRedis implements ITelemetryCacheAsync {
7
7
  private readonly log;
8
8
  private readonly keys;
@@ -13,7 +13,7 @@ export declare class TelemetryCacheInRedis implements ITelemetryCacheAsync {
13
13
  * @param keys Key builder.
14
14
  * @param redis Redis client.
15
15
  */
16
- constructor(log: ILogger, keys: KeyBuilderSS, redis: Redis);
16
+ constructor(log: ILogger, keys: KeyBuilderSS, redis: RedisAdapter);
17
17
  recordLatency(method: Method, latencyMs: number): Promise<number | void>;
18
18
  recordException(method: Method): Promise<number | void>;
19
19
  recordConfig(): Promise<number | void>;
@@ -1,15 +1,16 @@
1
+ /// <reference types="ioredis" />
1
2
  import { IUniqueKeysCacheBase } from '../types';
2
- import { Redis } from 'ioredis';
3
3
  import { UniqueKeysCacheInMemory } from '../inMemory/UniqueKeysCacheInMemory';
4
4
  import { ILogger } from '../../logger/types';
5
5
  import { UniqueKeysItemSs } from '../../sync/submitters/types';
6
+ import type { RedisAdapter } from './RedisAdapter';
6
7
  export declare class UniqueKeysCacheInRedis extends UniqueKeysCacheInMemory implements IUniqueKeysCacheBase {
7
8
  private readonly log;
8
9
  private readonly key;
9
10
  private readonly redis;
10
11
  private readonly refreshRate;
11
12
  private intervalId;
12
- constructor(log: ILogger, key: string, redis: Redis, uniqueKeysQueueSize?: number, refreshRate?: number);
13
+ constructor(log: ILogger, key: string, redis: RedisAdapter, uniqueKeysQueueSize?: number, refreshRate?: number);
13
14
  private postUniqueKeysInRedis;
14
15
  start(): void;
15
16
  stop(): Promise<boolean | import("ioredis").BooleanResponse | undefined>;
@@ -71,10 +71,10 @@ export declare class SplitsCachePluggable extends AbstractSplitsCacheAsync {
71
71
  */
72
72
  getSplitNames(): Promise<string[]>;
73
73
  /**
74
- * Get list of split names related to a given flag set names list.
75
- * The returned promise is resolved with the list of split names,
76
- * or rejected if any wrapper operation fails.
77
- */
74
+ * Get list of feature flag names related to a given list of flag set names.
75
+ * The returned promise is resolved with the list of feature flag names per flag set.
76
+ * It never rejects (If there is a wrapper error for some flag set, an empty set is returned for it).
77
+ */
78
78
  getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
79
79
  /**
80
80
  * Check traffic type existence.
@@ -8,6 +8,6 @@ export { validateSplit } from './split';
8
8
  export { validateSplits } from './splits';
9
9
  export { validateTrafficType } from './trafficType';
10
10
  export { validateIfNotDestroyed, validateIfOperational } from './isOperational';
11
- export { validateSplitExistance } from './splitExistance';
12
- export { validateTrafficTypeExistance } from './trafficTypeExistance';
11
+ export { validateSplitExistence } from './splitExistence';
12
+ export { validateTrafficTypeExistence } from './trafficTypeExistence';
13
13
  export { validatePreloadedData } from './preloadedData';
@@ -0,0 +1,7 @@
1
+ import { IReadinessManager } from '../../readiness/types';
2
+ import { ILogger } from '../../logger/types';
3
+ /**
4
+ * This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level.
5
+ * But it's not going to run on the input validation layer. In any case, the most compeling reason to use it as we do is to avoid going to Redis and get a split twice.
6
+ */
7
+ export declare function validateSplitExistence(log: ILogger, readinessManager: IReadinessManager, splitName: string, labelOrSplitObj: any, method: string): boolean;
@@ -0,0 +1,9 @@
1
+ import { ISplitsCacheBase } from '../../storages/types';
2
+ import { IReadinessManager } from '../../readiness/types';
3
+ import { SDKMode } from '../../types';
4
+ import { MaybeThenable } from '../../dtos/types';
5
+ import { ILogger } from '../../logger/types';
6
+ /**
7
+ * Separated from the previous method since on some cases it'll be async.
8
+ */
9
+ export declare function validateTrafficTypeExistence(log: ILogger, readinessManager: IReadinessManager, splitsCache: ISplitsCacheBase, mode: SDKMode, maybeTT: string, method: string): MaybeThenable<boolean>;
@@ -1,4 +1,3 @@
1
1
  export declare class RedisMock {
2
- private pipelineMethods;
3
2
  constructor();
4
3
  }