@datadog/flagging-core 0.1.0-alpha.9 → 0.1.0-preview.11

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 (101) hide show
  1. package/cjs/cache/abstract-assignment-cache.d.ts +39 -0
  2. package/cjs/cache/abstract-assignment-cache.d.ts.map +1 -0
  3. package/cjs/cache/abstract-assignment-cache.js +59 -0
  4. package/cjs/cache/abstract-assignment-cache.js.map +1 -0
  5. package/cjs/cache/index.d.ts +4 -0
  6. package/cjs/cache/index.d.ts.map +1 -0
  7. package/cjs/cache/index.js +20 -0
  8. package/cjs/cache/index.js.map +1 -0
  9. package/cjs/cache/lru-cache.d.ts +31 -0
  10. package/cjs/cache/lru-cache.d.ts.map +1 -0
  11. package/cjs/cache/lru-cache.js +85 -0
  12. package/cjs/cache/lru-cache.js.map +1 -0
  13. package/cjs/cache/lru-in-memory-assignment-cache.d.ts +16 -0
  14. package/cjs/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
  15. package/cjs/cache/lru-in-memory-assignment-cache.js +22 -0
  16. package/cjs/cache/lru-in-memory-assignment-cache.js.map +1 -0
  17. package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
  18. package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
  19. package/cjs/cache/non-expiring-in-memory-cache-assignment.js +17 -0
  20. package/cjs/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
  21. package/cjs/configuration/configuration.d.ts +12 -6
  22. package/cjs/configuration/configuration.d.ts.map +1 -1
  23. package/cjs/configuration/exposureEvent.d.ts +4 -0
  24. package/cjs/configuration/exposureEvent.d.ts.map +1 -0
  25. package/cjs/configuration/exposureEvent.js +33 -0
  26. package/cjs/configuration/exposureEvent.js.map +1 -0
  27. package/cjs/configuration/exposureEvent.types.d.ts +21 -0
  28. package/cjs/configuration/exposureEvent.types.d.ts.map +1 -0
  29. package/cjs/configuration/exposureEvent.types.js +3 -0
  30. package/cjs/configuration/exposureEvent.types.js.map +1 -0
  31. package/cjs/configuration/index.d.ts +2 -0
  32. package/cjs/configuration/index.d.ts.map +1 -1
  33. package/cjs/configuration/index.js +2 -0
  34. package/cjs/configuration/index.js.map +1 -1
  35. package/cjs/index.d.ts +2 -0
  36. package/cjs/index.d.ts.map +1 -1
  37. package/cjs/index.js +3 -1
  38. package/cjs/index.js.map +1 -1
  39. package/cjs/obfuscation.d.ts +9 -0
  40. package/cjs/obfuscation.d.ts.map +1 -0
  41. package/cjs/obfuscation.js +23 -0
  42. package/cjs/obfuscation.js.map +1 -0
  43. package/esm/cache/abstract-assignment-cache.d.ts +39 -0
  44. package/esm/cache/abstract-assignment-cache.d.ts.map +1 -0
  45. package/esm/cache/abstract-assignment-cache.js +53 -0
  46. package/esm/cache/abstract-assignment-cache.js.map +1 -0
  47. package/esm/cache/index.d.ts +4 -0
  48. package/esm/cache/index.d.ts.map +1 -0
  49. package/esm/cache/index.js +4 -0
  50. package/esm/cache/index.js.map +1 -0
  51. package/esm/cache/lru-cache.d.ts +31 -0
  52. package/esm/cache/lru-cache.d.ts.map +1 -0
  53. package/esm/cache/lru-cache.js +81 -0
  54. package/esm/cache/lru-cache.js.map +1 -0
  55. package/esm/cache/lru-in-memory-assignment-cache.d.ts +16 -0
  56. package/esm/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
  57. package/esm/cache/lru-in-memory-assignment-cache.js +18 -0
  58. package/esm/cache/lru-in-memory-assignment-cache.js.map +1 -0
  59. package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
  60. package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
  61. package/esm/cache/non-expiring-in-memory-cache-assignment.js +13 -0
  62. package/esm/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
  63. package/esm/configuration/configuration.d.ts +52 -0
  64. package/esm/configuration/configuration.d.ts.map +1 -0
  65. package/esm/configuration/configuration.js +2 -0
  66. package/esm/configuration/configuration.js.map +1 -0
  67. package/esm/configuration/exposureEvent.d.ts +4 -0
  68. package/esm/configuration/exposureEvent.d.ts.map +1 -0
  69. package/esm/configuration/exposureEvent.js +30 -0
  70. package/esm/configuration/exposureEvent.js.map +1 -0
  71. package/esm/configuration/exposureEvent.types.d.ts +21 -0
  72. package/esm/configuration/exposureEvent.types.d.ts.map +1 -0
  73. package/esm/configuration/exposureEvent.types.js +2 -0
  74. package/esm/configuration/exposureEvent.types.js.map +1 -0
  75. package/esm/configuration/index.d.ts +5 -0
  76. package/esm/configuration/index.d.ts.map +1 -0
  77. package/esm/configuration/index.js +5 -0
  78. package/esm/configuration/index.js.map +1 -0
  79. package/esm/configuration/wire.d.ts +12 -0
  80. package/esm/configuration/wire.d.ts.map +1 -0
  81. package/esm/configuration/wire.js +41 -0
  82. package/esm/configuration/wire.js.map +1 -0
  83. package/esm/index.d.ts +4 -0
  84. package/esm/index.d.ts.map +1 -0
  85. package/esm/index.js +6 -0
  86. package/esm/index.js.map +1 -0
  87. package/esm/obfuscation.d.ts +9 -0
  88. package/esm/obfuscation.d.ts.map +1 -0
  89. package/esm/obfuscation.js +16 -0
  90. package/esm/obfuscation.js.map +1 -0
  91. package/package.json +12 -5
  92. package/jest.config.js +0 -15
  93. package/src/configuration/configuration.ts +0 -52
  94. package/src/configuration/index.ts +0 -2
  95. package/src/configuration/wire.ts +0 -58
  96. package/src/global.d.ts +0 -3
  97. package/src/index.ts +0 -4
  98. package/tsconfig.cjs.json +0 -13
  99. package/tsconfig.esm.json +0 -13
  100. package/tsconfig.json +0 -12
  101. package/tsconfig.test.json +0 -8
@@ -0,0 +1,39 @@
1
+ import type { ExposureEvent } from '../configuration';
2
+ export type AssignmentCacheKey = Pick<ExposureEvent, 'flag' | 'subject'>;
3
+ export type AssignmentCacheEntry = ExposureEvent;
4
+ /** Converts an {@link AssignmentCacheKey} to a string. */
5
+ export declare function assignmentCacheKeyToString(exposureEvent: AssignmentCacheKey | ExposureEvent): string;
6
+ /** Converts an {@link AssignmentCacheValue} to a string. */
7
+ export declare function assignmentCacheValueToString(cacheValue: AssignmentCacheEntry): string;
8
+ export interface AsyncMap<K, V> {
9
+ get(key: K): Promise<V | undefined>;
10
+ set(key: K, value: V): Promise<void>;
11
+ has(key: K): Promise<boolean>;
12
+ }
13
+ export interface AssignmentCache {
14
+ init(): Promise<void>;
15
+ set(key: AssignmentCacheEntry): void;
16
+ has(key: AssignmentCacheEntry): boolean;
17
+ clear(): Promise<void> | void;
18
+ }
19
+ export declare abstract class AbstractAssignmentCache<T extends Map<string, string>> implements AssignmentCache {
20
+ protected readonly delegate: T;
21
+ protected constructor(delegate: T);
22
+ init(): Promise<void>;
23
+ /** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
24
+ has(entry: AssignmentCacheEntry): boolean;
25
+ get(key: AssignmentCacheKey): string | undefined;
26
+ /**
27
+ * Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
28
+ * will be overwritten.
29
+ */
30
+ set(entry: AssignmentCacheEntry): void;
31
+ /**
32
+ * Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
33
+ * {@link string}s.
34
+ */
35
+ entries(): IterableIterator<[string, string]>;
36
+ /** Clears all entries from the cache. */
37
+ clear(): void;
38
+ }
39
+ //# sourceMappingURL=abstract-assignment-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-assignment-cache.d.ts","sourceRoot":"","sources":["../../src/cache/abstract-assignment-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AACxE,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAEhD,0DAA0D;AAC1D,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,kBAAkB,GAAG,aAAa,GAAG,MAAM,CAWpG;AAED,4DAA4D;AAC5D,wBA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ule", { value: true });
3
+ exports.AbstractAssignmentCache = void 0;
4
+ exports.assignmentCacheKeyToString = assignmentCacheKeyToString;
5
+ exports.assignmentCacheValueToString = assignmentCacheValueToString;
6
+ const obfuscation_1 = require("../obfuscation");
7
+ /** Converts an {@link AssignmentCacheKey} to a string. */
8
+ function assignmentCacheKeyToString(exposureEvent) {
9
+ const key = {
10
+ flag: {
11
+ key: exposureEvent.flag.key,
12
+ },
13
+ subject: {
14
+ id: exposureEvent.subject.id,
15
+ attributes: exposureEvent.subject.attributes,
16
+ },
17
+ };
18
+ return (0, obfuscation_1.getMD5Hash)(JSON.stringify(key));
19
+ }
20
+ /** Converts an {@link AssignmentCacheValue} to a string. */
21
+ function assignmentCacheValueToString(cacheValue) {
22
+ return (0, obfuscation_1.getMD5Hash)(JSON.stringify(cacheValue));
23
+ }
24
+ class AbstractAssignmentCache {
25
+ // key -> variation value hash
26
+ constructor(delegate) {
27
+ this.delegate = delegate;
28
+ }
29
+ init() {
30
+ return Promise.resolve();
31
+ }
32
+ /** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
33
+ has(entry) {
34
+ return this.get(entry) === assignmentCacheValueToString(entry);
35
+ }
36
+ get(key) {
37
+ return this.delegate.get(assignmentCacheKeyToString(key));
38
+ }
39
+ /**
40
+ * Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
41
+ * will be overwritten.
42
+ */
43
+ set(entry) {
44
+ this.delegate.set(assignmentCacheKeyToString(entry), assignmentCacheValueToString(entry));
45
+ }
46
+ /**
47
+ * Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
48
+ * {@link string}s.
49
+ */
50
+ entries() {
51
+ return this.delegate.entries();
52
+ }
53
+ /** Clears all entries from the cache. */
54
+ clear() {
55
+ this.delegate.clear();
56
+ }
57
+ }
58
+ exports.AbstractAssignmentCache = AbstractAssignmentCache;
59
+ //# sourceMappingURL=abstract-assignment-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-assignment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AGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;IAChC,CAAC;IAED,yCAAyC;IACzC,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;CACF;AArCD,0DAqCC"}
@@ -0,0 +1,4 @@
1
+ export * from './abstract-assignment-cache';
2
+ export * from './lru-in-memory-assignment-cache';
3
+ export * from './non-expiring-in-memory-cache-assignment';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./abstract-assignment-cache"), exports);
18
+ __exportStar(require("./lru-in-memory-assignment-cache"), exports);
19
+ __exportStar(require("./non-expiring-in-memory-cache-assignment"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA2C;AAC3C,mEAAgD;AAChD,4EAAyD"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * LRUCache is a simple implementation of a Least Recently Used (LRU) cache.
3
+ *
4
+ * Old items are evicted when the cache reaches its capacity.
5
+ *
6
+ * The cache is implemented as a Map, which maintains insertion order:
7
+ * ```
8
+ * Iteration happens in insertion order, which corresponds to the order in which each key-value pair
9
+ * was first inserted into the map by the set() method (that is, there wasn't a key with the same
10
+ * value already in the map when set() was called).
11
+ * ```
12
+ * Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
13
+ */
14
+ export declare class LRUCache implements Map<string, string> {
15
+ protected readonly capacity: number;
16
+ protected readonly cache: Map<string, string>;
17
+ [Symbol.toStringTag]: string;
18
+ constructor(capacity: number);
19
+ [Symbol.iterator](): IterableIterator<[string, string]>;
20
+ forEach(callbackFn: (value: string, key: string, map: Map<string, string>) => void): void;
21
+ readonly size: number;
22
+ entries(): IterableIterator<[string, string]>;
23
+ clear(): void;
24
+ delete(key: string): boolean;
25
+ keys(): IterableIterator<string>;
26
+ values(): IterableIterator<string>;
27
+ has(key: string): boolean;
28
+ get(key: string): string | undefined;
29
+ set(key: string, value: string): this;
30
+ }
31
+ //# sourceMappingURL=lru-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../src/cache/lru-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,YAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAL/C,SAAS,CAAC,QAAQ,CAAC,KAAK,sBAA6B;IAGrD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;gBAEG,QAAQ,EAAE,MAAM;IAE/C,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIvD,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,IAAI;IAIzF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAkB;IAEvC,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI7C,KAAK;IAIL,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIhC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAoBpC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAqBtC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LRUCache = void 0;
4
+ /**
5
+ * LRUCache is a simple implementation of a Least Recently Used (LRU) cache.
6
+ *
7
+ * Old items are evicted when the cache reaches its capacity.
8
+ *
9
+ * The cache is implemented as a Map, which maintains insertion order:
10
+ * ```
11
+ * Iteration happens in insertion order, which corresponds to the order in which each key-value pair
12
+ * was first inserted into the map by the set() method (that is, there wasn't a key with the same
13
+ * value already in the map when set() was called).
14
+ * ```
15
+ * Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
16
+ */
17
+ class LRUCache {
18
+ constructor(capacity) {
19
+ this.capacity = capacity;
20
+ this.cache = new Map();
21
+ this.size = this.cache.size;
22
+ }
23
+ [(Symbol.toStringTag, Symbol.iterator)]() {
24
+ return this.cache[Symbol.iterator]();
25
+ }
26
+ forEach(callbackFn) {
27
+ this.cache.forEach(callbackFn);
28
+ }
29
+ entries() {
30
+ return this.cache.entries();
31
+ }
32
+ clear() {
33
+ this.cache.clear();
34
+ }
35
+ delete(key) {
36
+ return this.cache.delete(key);
37
+ }
38
+ keys() {
39
+ return this.cache.keys();
40
+ }
41
+ values() {
42
+ return this.cache.values();
43
+ }
44
+ has(key) {
45
+ return this.cache.has(key);
46
+ }
47
+ get(key) {
48
+ if (!this.has(key)) {
49
+ return undefined;
50
+ }
51
+ const value = this.cache.get(key);
52
+ if (value !== undefined) {
53
+ // the delete and set operations are used together to ensure that the most recently accessed
54
+ // or added item is always considered the "newest" in terms of access order.
55
+ // This is crucial for maintaining the correct order of elements in the cache,
56
+ // which directly impacts which item is considered the least recently used (LRU) and
57
+ // thus eligible for eviction when the cache reaches its capacity.
58
+ this.delete(key);
59
+ this.cache.set(key, value);
60
+ }
61
+ return value;
62
+ }
63
+ set(key, value) {
64
+ if (this.capacity === 0) {
65
+ return this;
66
+ }
67
+ if (this.cache.has(key)) {
68
+ this.cache.delete(key);
69
+ }
70
+ else if (this.cache.size >= this.capacity) {
71
+ // To evict the least recently used (LRU) item, we retrieve the first key in the Map.
72
+ // This is possible because the Map object in JavaScript maintains the insertion order of the keys.
73
+ // Therefore, the first key represents the oldest entry, which is the least recently used item in our cache.
74
+ // We use Map.prototype.keys().next().value to obtain this oldest key and then delete it from the cache.
75
+ const oldestKey = this.cache.keys().next().value;
76
+ if (oldestKey) {
77
+ this.delete(oldestKey);
78
+ }
79
+ }
80
+ this.cache.set(key, value);
81
+ return this;
82
+ }
83
+ }
84
+ exports.LRUCache = LRUCache;
85
+ //# sourceMappingURL=lru-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../src/cache/lru-cache.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,QAAQ;IAMnB,YAA+B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAL5B,UAAK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AC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,qFAAqF;YACrF,mGAAmG;YACnG,4GAA4G;YAC5G,wGAAwG;YACxG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAChD,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAnFD,4BAmFC"}
@@ -0,0 +1,16 @@
1
+ import { AbstractAssignmentCache } from './abstract-assignment-cache';
2
+ import { LRUCache } from './lru-cache';
3
+ /**
4
+ * A cache that uses the LRU algorithm to evict the least recently used items.
5
+ *
6
+ * It is used to limit the size of the cache.
7
+ *
8
+ * The primary use case is for server-side SDKs, where the cache is shared across
9
+ * multiple users. In this case, the cache size should be set to the maximum number
10
+ * of users that can be active at the same time.
11
+ * @param {number} maxSize - Maximum cache size
12
+ */
13
+ export declare class LRUInMemoryAssignmentCache extends AbstractAssignmentCache<LRUCache> {
14
+ constructor(maxSize: number);
15
+ }
16
+ //# sourceMappingURL=lru-in-memory-assignment-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-in-memory-assignment-cache.d.ts","sourceRoot":"","sources":["../../src/cache/lru-in-memory-assignment-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;;;;;;;GASG;AACH,qBAAa,0BAA2B,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;gBACnE,OAAO,EAAE,MAAM;CAG5B"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LRUInMemoryAssignmentCache = void 0;
4
+ const abstract_assignment_cache_1 = require("./abstract-assignment-cache");
5
+ const lru_cache_1 = require("./lru-cache");
6
+ /**
7
+ * A cache that uses the LRU algorithm to evict the least recently used items.
8
+ *
9
+ * It is used to limit the size of the cache.
10
+ *
11
+ * The primary use case is for server-side SDKs, where the cache is shared across
12
+ * multiple users. In this case, the cache size should be set to the maximum number
13
+ * of users that can be active at the same time.
14
+ * @param {number} maxSize - Maximum cache size
15
+ */
16
+ class LRUInMemoryAssignmentCache extends abstract_assignment_cache_1.AbstractAssignmentCache {
17
+ constructor(maxSize) {
18
+ super(new lru_cache_1.LRUCache(maxSize));
19
+ }
20
+ }
21
+ exports.LRUInMemoryAssignmentCache = LRUInMemoryAssignmentCache;
22
+ //# sourceMappingURL=lru-in-memory-assignment-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-in-memory-assignment-cache.js","sourceRoot":"","sources":["../../src/cache/lru-in-memory-assignment-cache.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AACrE,2CAAsC;AAEtC;;;;;;;;;GASG;AACH,MAAa,0BAA2B,SAAQ,mDAAiC;IAC/E,YAAY,OAAe;QACzB,KAAK,CAAC,IAAI,oBAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9B,CAAC;CACF;AAJD,gEAIC"}
@@ -0,0 +1,11 @@
1
+ import { AbstractAssignmentCache } from './abstract-assignment-cache';
2
+ /**
3
+ * A cache that never expires.
4
+ *
5
+ * The primary use case is for client-side SDKs, where the cache is only used
6
+ * for a single user.
7
+ */
8
+ export declare class NonExpiringInMemoryAssignmentCache extends AbstractAssignmentCache<Map<string, string>> {
9
+ constructor(store?: Map<string, string>);
10
+ }
11
+ //# sourceMappingURL=non-expiring-in-memory-cache-assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-expiring-in-memory-cache-assignment.d.ts","sourceRoot":"","sources":["../../src/cache/non-expiring-in-memory-cache-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE;;;;;GAKG;AACH,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACtF,KAAK,sBAA4B;CAG9C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NonExpiringInMemoryAssignmentCache = void 0;
4
+ const abstract_assignment_cache_1 = require("./abstract-assignment-cache");
5
+ /**
6
+ * A cache that never expires.
7
+ *
8
+ * The primary use case is for client-side SDKs, where the cache is only used
9
+ * for a single user.
10
+ */
11
+ class NonExpiringInMemoryAssignmentCache extends abstract_assignment_cache_1.AbstractAssignmentCache {
12
+ constructor(store = new Map()) {
13
+ super(store);
14
+ }
15
+ }
16
+ exports.NonExpiringInMemoryAssignmentCache = NonExpiringInMemoryAssignmentCache;
17
+ //# sourceMappingURL=non-expiring-in-memory-cache-assignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-expiring-in-memory-cache-assignment.js","sourceRoot":"","sources":["../../src/cache/non-expiring-in-memory-cache-assignment.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AAErE;;;;;GAKG;AACH,MAAa,kCAAmC,SAAQ,mDAA4C;IAClG,YAAY,QAAQ,IAAI,GAAG,EAAkB;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;CACF;AAJD,gFAIC"}
@@ -1,4 +1,4 @@
1
- import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/web-sdk';
1
+ import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/core';
2
2
  /**
3
3
  * Internal flags configuration for DatadogProvider.
4
4
  */
@@ -14,10 +14,10 @@ export type PrecomputedConfiguration = {
14
14
  };
15
15
  /** @internal */
16
16
  export type FlagTypeToValue<T extends FlagValueType> = {
17
- ['boolean']: boolean;
18
- ['string']: string;
19
- ['number']: number;
20
- ['object']: JsonValue;
17
+ boolean: boolean;
18
+ string: string;
19
+ number: number;
20
+ object: JsonValue;
21
21
  }[T];
22
22
  /** @internal
23
23
  * Timestamp in milliseconds since Unix Epoch.
@@ -28,7 +28,7 @@ export type PrecomputedConfigurationResponse = {
28
28
  data: {
29
29
  attributes: {
30
30
  /** When configuration was generated. */
31
- createdAt: number;
31
+ createdAt: string;
32
32
  flags: Record<string, PrecomputedFlag>;
33
33
  };
34
34
  };
@@ -43,4 +43,10 @@ export type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
43
43
  doLog: boolean;
44
44
  extraLogging: Record<string, unknown>;
45
45
  };
46
+ /** @internal */
47
+ export type PrecomputedFlagMetadata = {
48
+ allocationKey: string;
49
+ variationType: FlagValueType;
50
+ doLog: boolean;
51
+ };
46
52
  //# sourceMappingURL=configuration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEzG;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB;IAChB,W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,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,aAAa,CAAA;IAC5B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { EvaluationContext, EvaluationDetails, FlagValue } from '@openfeature/core';
2
+ import type { ExposureEvent } from './exposureEvent.types';
3
+ export declare function createExposureEvent<T extends FlagValue>(context: EvaluationContext, details: EvaluationDetails<T>): ExposureEvent | undefined;
4
+ //# sourceMappingURL=exposureEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EACrD,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,aAAa,GAAG,SAAS,CA8B3B"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExposureEvent = createExposureEvent;
4
+ function createExposureEvent(context, details) {
5
+ var _a, _b;
6
+ // Only log if doLog flag is true
7
+ if (!((_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.doLog)) {
8
+ return;
9
+ }
10
+ // Skip logging if allocation key or variant is missing (this should never happen)
11
+ const allocationKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.allocationKey;
12
+ const variantKey = details.variant;
13
+ if (!allocationKey || !variantKey) {
14
+ return;
15
+ }
16
+ const { targetingKey: id = '', ...attributes } = context;
17
+ return {
18
+ allocation: {
19
+ key: allocationKey,
20
+ },
21
+ flag: {
22
+ key: details.flagKey,
23
+ },
24
+ variant: {
25
+ key: variantKey,
26
+ },
27
+ subject: {
28
+ id,
29
+ attributes,
30
+ },
31
+ };
32
+ }
33
+ //# sourceMappingURL=exposureEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":";;AAGA,kDAiCC;AAjCD,SAAgB,mBAAmB,CACjC,OAA0B,EAC1B,OAA6B;;IAE7B,iCAAiC;IACjC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,KAAK,CAAA,EAAE,CAAC;QACjC,OAAM;IACR,CAAC;IAED,kFAAkF;IAClF,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,aAAuB,CAAA;IACnE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAA;IAClC,IAAI,CAAC,aAAa,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,OAAM;IACR,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAA;IAExD,OAAO;QACL,UAAU,EAAE;YACV,GAAG,EAAE,aAAa;SACnB;QACD,IAAI,EAAE;YACJ,GAAG,EAAE,OAAO,CAAC,OAAO;SACrB;QACD,OAAO,EAAE;YACP,GAAG,EAAE,UAAU;SAChB;QACD,OAAO,EAAE;YACP,EAAE;YACF,UAAU;SACX;KACsB,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { EvaluationContext } from '@openfeature/core';
2
+ export interface ExposureEvent {
3
+ allocation: {
4
+ key: string;
5
+ };
6
+ flag: {
7
+ key: string;
8
+ };
9
+ variant: {
10
+ key: string;
11
+ };
12
+ subject: {
13
+ id: string;
14
+ attributes: EvaluationContext;
15
+ };
16
+ }
17
+ export interface ExposureEventWithTimestamp extends ExposureEvent {
18
+ /** Unix timestamp in milliseconds */
19
+ timestamp: number;
20
+ }
21
+ //# sourceMappingURL=exposureEvent.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.types.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE;QACV,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,iBAAiB,CAAA;KAC9B,CAAA;CACF;AAED,MAAM,WAAW,0BAA2B,SAAQ,aAAa;IAC/D,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=exposureEvent.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.types.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,5 @@
1
1
  export * from './configuration';
2
+ export * from './exposureEvent';
3
+ export * from './exposureEvent.types';
2
4
  export * from './wire';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,QAAQ,CAAA"}
@@ -15,5 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./configuration"), exports);
18
+ __exportStar(require("./exposureEvent"), exports);
19
+ __exportStar(require("./exposureEvent.types"), exports);
18
20
  __exportStar(require("./wire"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,yCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,yCAAsB"}
package/cjs/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ export * from './cache';
1
2
  export * from './configuration';
3
+ export * from './obfuscation';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
package/cjs/index.js CHANGED
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cache"), exports);
17
18
  __exportStar(require("./configuration"), exports);
19
+ __exportStar(require("./obfuscation"), exports);
18
20
  // Build environment placeholder for testing
19
- const SDK_VERSION = "dev";
21
+ const _SDK_VERSION = "dev";
20
22
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAE/B,4CAA4C;AAC5C,MAAM,WAAW,GAAG,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,kDAA+B;AAC/B,gDAA6B;AAE7B,4CAA4C;AAC5C,MAAM,YAAY,GAAG,0BAA0B,CAAA"}
@@ -0,0 +1,9 @@
1
+ export declare function getMD5Hash(input: string, salt?: string): string;
2
+ /**
3
+ * Builds a storage key suffix from an API key.
4
+ * @param apiKey - The API key to build the suffix from
5
+ * @returns A string suffix for storage keys
6
+ * @public
7
+ */
8
+ export declare function buildStorageKeySuffix(apiKey: string): string;
9
+ //# sourceMappingURL=obfuscation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obfuscation.d.ts","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getMD5Hash = getMD5Hash;
7
+ exports.buildStorageKeySuffix = buildStorageKeySuffix;
8
+ const spark_md5_1 = __importDefault(require("spark-md5"));
9
+ function getMD5Hash(input, salt = '') {
10
+ return new spark_md5_1.default().append(salt).append(input).end();
11
+ }
12
+ /**
13
+ * Builds a storage key suffix from an API key.
14
+ * @param apiKey - The API key to build the suffix from
15
+ * @returns A string suffix for storage keys
16
+ * @public
17
+ */
18
+ function buildStorageKeySuffix(apiKey) {
19
+ // Note that we hash the API key and use the first 16 characters of the digest.
20
+ const hashed = getMD5Hash(apiKey);
21
+ return hashed.slice(0, 16);
22
+ }
23
+ //# sourceMappingURL=obfuscation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":";;;;;AAEA,gCAEC;AAQD,sDAIC;AAhBD,0DAAgC;AAEhC,SAAgB,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,mBAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAc;IAClD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { ExposureEvent } from '../configuration';
2
+ export type AssignmentCacheKey = Pick<ExposureEvent, 'flag' | 'subject'>;
3
+ export type AssignmentCacheEntry = ExposureEvent;
4
+ /** Converts an {@link AssignmentCacheKey} to a string. */
5
+ export declare function assignmentCacheKeyToString(exposureEvent: AssignmentCacheKey | ExposureEvent): string;
6
+ /** Converts an {@link AssignmentCacheValue} to a string. */
7
+ export declare function assignmentCacheValueToString(cacheValue: AssignmentCacheEntry): string;
8
+ export interface AsyncMap<K, V> {
9
+ get(key: K): Promise<V | undefined>;
10
+ set(key: K, value: V): Promise<void>;
11
+ has(key: K): Promise<boolean>;
12
+ }
13
+ export interface AssignmentCache {
14
+ init(): Promise<void>;
15
+ set(key: AssignmentCacheEntry): void;
16
+ has(key: AssignmentCacheEntry): boolean;
17
+ clear(): Promise<void> | void;
18
+ }
19
+ export declare abstract class AbstractAssignmentCache<T extends Map<string, string>> implements AssignmentCache {
20
+ protected readonly delegate: T;
21
+ protected constructor(delegate: T);
22
+ init(): Promise<void>;
23
+ /** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
24
+ has(entry: AssignmentCacheEntry): boolean;
25
+ get(key: AssignmentCacheKey): string | undefined;
26
+ /**
27
+ * Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
28
+ * will be overwritten.
29
+ */
30
+ set(entry: AssignmentCacheEntry): void;
31
+ /**
32
+ * Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
33
+ * {@link string}s.
34
+ */
35
+ entries(): IterableIterator<[string, string]>;
36
+ /** Clears all entries from the cache. */
37
+ clear(): void;
38
+ }
39
+ //# sourceMappingURL=abstract-assignment-cache.d.ts.map