@splitsoftware/splitio-commons 1.6.2-rc.13 → 1.6.2-rc.14

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 (50) hide show
  1. package/cjs/storages/KeyBuilderSS.js +4 -43
  2. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +3 -3
  3. package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +2 -19
  4. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +4 -4
  5. package/cjs/storages/inRedis/index.js +2 -2
  6. package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +3 -3
  7. package/cjs/storages/pluggable/ImpressionsCachePluggable.js +2 -19
  8. package/cjs/storages/pluggable/TelemetryCachePluggable.js +4 -4
  9. package/cjs/storages/pluggable/inMemoryWrapper.js +8 -6
  10. package/cjs/storages/pluggable/index.js +2 -2
  11. package/cjs/storages/utils.js +73 -0
  12. package/esm/storages/KeyBuilderSS.js +1 -37
  13. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +3 -3
  14. package/esm/storages/inRedis/ImpressionsCacheInRedis.js +2 -19
  15. package/esm/storages/inRedis/TelemetryCacheInRedis.js +1 -1
  16. package/esm/storages/inRedis/index.js +1 -1
  17. package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +3 -3
  18. package/esm/storages/pluggable/ImpressionsCachePluggable.js +2 -19
  19. package/esm/storages/pluggable/TelemetryCachePluggable.js +1 -1
  20. package/esm/storages/pluggable/inMemoryWrapper.js +8 -6
  21. package/esm/storages/pluggable/index.js +1 -1
  22. package/esm/storages/utils.js +65 -0
  23. package/package.json +1 -1
  24. package/src/services/splitApi.ts +2 -2
  25. package/src/storages/KeyBuilderSS.ts +2 -44
  26. package/src/storages/inMemory/AttributesCacheInMemory.ts +7 -7
  27. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +3 -3
  28. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +2 -22
  29. package/src/storages/inRedis/TelemetryCacheInRedis.ts +2 -1
  30. package/src/storages/inRedis/index.ts +1 -1
  31. package/src/storages/pluggable/ImpressionCountsCachePluggable.ts +3 -3
  32. package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -23
  33. package/src/storages/pluggable/TelemetryCachePluggable.ts +2 -1
  34. package/src/storages/pluggable/inMemoryWrapper.ts +6 -6
  35. package/src/storages/pluggable/index.ts +1 -1
  36. package/src/storages/types.ts +4 -4
  37. package/src/storages/utils.ts +78 -0
  38. package/src/sync/submitters/types.ts +2 -0
  39. package/src/trackers/impressionsTracker.ts +2 -2
  40. package/src/trackers/strategy/strategyDebug.ts +4 -4
  41. package/src/utils/redis/RedisMock.ts +5 -5
  42. package/types/storages/KeyBuilderSS.d.ts +1 -3
  43. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +0 -1
  44. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +1 -2
  45. package/types/storages/types.d.ts +4 -4
  46. package/types/storages/utils.d.ts +8 -0
  47. package/types/sync/submitters/types.d.ts +2 -0
  48. package/cjs/storages/metadataBuilder.js +0 -12
  49. package/esm/storages/metadataBuilder.js +0 -8
  50. package/src/storages/metadataBuilder.ts +0 -11
@@ -12,9 +12,9 @@ const ASYNC_METHODS = ['rpush', 'hincrby'];
12
12
  const PIPELINE_METHODS = ['rpush', 'hincrby'];
13
13
 
14
14
  export class RedisMock {
15
-
15
+
16
16
  private pipelineMethods: any = { exec: jest.fn(asyncFunction) }
17
-
17
+
18
18
  constructor() {
19
19
  IDENTITY_METHODS.forEach(method => {
20
20
  this[method] = jest.fn(identityFunction);
@@ -25,9 +25,9 @@ export class RedisMock {
25
25
  PIPELINE_METHODS.forEach(method => {
26
26
  this.pipelineMethods[method] = this[method];
27
27
  });
28
-
28
+
29
29
  this.pipeline = jest.fn(() => {return this.pipelineMethods;});
30
30
  }
31
-
32
-
31
+
32
+
33
33
  }
@@ -1,6 +1,7 @@
1
1
  import { KeyBuilder } from './KeyBuilder';
2
2
  import { IMetadata } from '../dtos/types';
3
3
  import { Method } from '../sync/submitters/types';
4
+ export declare const METHOD_NAMES: Record<Method, string>;
4
5
  export declare class KeyBuilderSS extends KeyBuilder {
5
6
  latencyPrefix: string;
6
7
  exceptionPrefix: string;
@@ -17,6 +18,3 @@ export declare class KeyBuilderSS extends KeyBuilder {
17
18
  buildExceptionKey(method: Method): string;
18
19
  buildInitKey(): string;
19
20
  }
20
- export declare function parseMetadata(field: string): [metadata: string] | string;
21
- export declare function parseExceptionField(field: string): [metadata: string, method: Method] | string;
22
- export declare function parseLatencyField(field: string): [metadata: string, method: Method, bucket: number] | string;
@@ -11,7 +11,6 @@ export declare class ImpressionsCacheInRedis implements IImpressionsCacheAsync {
11
11
  private readonly metadata;
12
12
  constructor(log: ILogger, key: string, redis: Redis, metadata: IMetadata);
13
13
  track(impressions: ImpressionDTO[]): Promise<void>;
14
- private _toJSON;
15
14
  count(): Promise<number>;
16
15
  drop(count?: number): Promise<any>;
17
16
  popNWithMetadata(count: number): Promise<StoredImpressionWithMetadata[]>;
@@ -1,8 +1,8 @@
1
1
  import { IPluggableStorageWrapper, IImpressionsCacheAsync } from '../types';
2
2
  import { IMetadata } from '../../dtos/types';
3
3
  import { ImpressionDTO } from '../../types';
4
- import { ILogger } from '../../logger/types';
5
4
  import { StoredImpressionWithMetadata } from '../../sync/submitters/types';
5
+ import { ILogger } from '../../logger/types';
6
6
  export declare class ImpressionsCachePluggable implements IImpressionsCacheAsync {
7
7
  private readonly log;
8
8
  private readonly key;
@@ -16,7 +16,6 @@ export declare class ImpressionsCachePluggable implements IImpressionsCacheAsync
16
16
  * or rejected if the wrapper operation fails.
17
17
  */
18
18
  track(impressions: ImpressionDTO[]): Promise<void>;
19
- private _toJSON;
20
19
  /**
21
20
  * Returns a promise that resolves with the count of stored impressions, or 0 if there was some error.
22
21
  * The promise will never be rejected.
@@ -64,21 +64,21 @@ export interface IPluggableStorageWrapper {
64
64
  getMany: (keys: string[]) => Promise<(string | null)[]>;
65
65
  /** Integer operations */
66
66
  /**
67
- * Increments the number stored at `key` by `increment` (or 1 if `increment` is not provided), or set it to `increment` (or 1) if the value doesn't exist.
67
+ * Increments the number stored at `key` by `increment`, or set it to `increment` if the value doesn't exist.
68
68
  *
69
69
  * @function incr
70
70
  * @param {string} key Key to increment
71
- * @param {number} increment Value to increment by
71
+ * @param {number} increment Value to increment by. Defaults to 1.
72
72
  * @returns {Promise<number>} A promise that resolves with the value of key after the increment. The promise rejects if the operation fails,
73
73
  * for example, if there is a connection error or the key contains a string that can not be represented as integer.
74
74
  */
75
75
  incr: (key: string, increment?: number) => Promise<number>;
76
76
  /**
77
- * Decrements the number stored at `key` by `decrement` (or 1 if `decrement` is not provided), or set it to minus `decrement` (or minus 1) if the value doesn't exist.
77
+ * Decrements the number stored at `key` by `decrement`, or set it to minus `decrement` if the value doesn't exist.
78
78
  *
79
79
  * @function decr
80
80
  * @param {string} key Key to decrement
81
- * @param {number} decrement Value to decrement by
81
+ * @param {number} decrement Value to decrement by. Defaults to 1.
82
82
  * @returns {Promise<number>} A promise that resolves with the value of key after the decrement. The promise rejects if the operation fails,
83
83
  * for example, if there is a connection error or the key contains a string that can not be represented as integer.
84
84
  */
@@ -0,0 +1,8 @@
1
+ import { IMetadata } from '../dtos/types';
2
+ import { Method } from '../sync/submitters/types';
3
+ import { ImpressionDTO, ISettings } from '../types';
4
+ export declare function metadataBuilder(settings: Pick<ISettings, 'version' | 'runtime'>): IMetadata;
5
+ export declare function impressionsToJSON(impressions: ImpressionDTO[], metadata: IMetadata): string[];
6
+ export declare function parseMetadata(field: string): [metadata: string] | string;
7
+ export declare function parseExceptionField(field: string): [metadata: string, method: Method] | string;
8
+ export declare function parseLatencyField(field: string): [metadata: string, method: Method, bucket: number] | string;
@@ -69,6 +69,8 @@ export declare type StoredImpressionWithMetadata = {
69
69
  c: number;
70
70
  /** time */
71
71
  m: number;
72
+ /** previous time */
73
+ pt?: number;
72
74
  };
73
75
  };
74
76
  export declare type StoredEventWithMetadata = {
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.metadataBuilder = void 0;
4
- var constants_1 = require("../utils/constants");
5
- function metadataBuilder(settings) {
6
- return {
7
- s: settings.version,
8
- i: settings.runtime.ip || constants_1.UNKNOWN,
9
- n: settings.runtime.hostname || constants_1.UNKNOWN,
10
- };
11
- }
12
- exports.metadataBuilder = metadataBuilder;
@@ -1,8 +0,0 @@
1
- import { UNKNOWN } from '../utils/constants';
2
- export function metadataBuilder(settings) {
3
- return {
4
- s: settings.version,
5
- i: settings.runtime.ip || UNKNOWN,
6
- n: settings.runtime.hostname || UNKNOWN,
7
- };
8
- }
@@ -1,11 +0,0 @@
1
- import { IMetadata } from '../dtos/types';
2
- import { ISettings } from '../types';
3
- import { UNKNOWN } from '../utils/constants';
4
-
5
- export function metadataBuilder(settings: Pick<ISettings, 'version' | 'runtime'>): IMetadata {
6
- return {
7
- s: settings.version,
8
- i: settings.runtime.ip || UNKNOWN,
9
- n: settings.runtime.hostname || UNKNOWN,
10
- };
11
- }