@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 @@
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,C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IACH,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI7C,yCAAyC;IACzC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,53 @@
1
+ import { getMD5Hash } from '../obfuscation';
2
+ /** Converts an {@link AssignmentCacheKey} to a string. */
3
+ export function assignmentCacheKeyToString(exposureEvent) {
4
+ const key = {
5
+ flag: {
6
+ key: exposureEvent.flag.key,
7
+ },
8
+ subject: {
9
+ id: exposureEvent.subject.id,
10
+ attributes: exposureEvent.subject.attributes,
11
+ },
12
+ };
13
+ return getMD5Hash(JSON.stringify(key));
14
+ }
15
+ /** Converts an {@link AssignmentCacheValue} to a string. */
16
+ export function assignmentCacheValueToString(cacheValue) {
17
+ return getMD5Hash(JSON.stringify(cacheValue));
18
+ }
19
+ export class AbstractAssignmentCache {
20
+ // key -> variation value hash
21
+ constructor(delegate) {
22
+ this.delegate = delegate;
23
+ }
24
+ init() {
25
+ return Promise.resolve();
26
+ }
27
+ /** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
28
+ has(entry) {
29
+ return this.get(entry) === assignmentCacheValueToString(entry);
30
+ }
31
+ get(key) {
32
+ return this.delegate.get(assignmentCacheKeyToString(key));
33
+ }
34
+ /**
35
+ * Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
36
+ * will be overwritten.
37
+ */
38
+ set(entry) {
39
+ this.delegate.set(assignmentCacheKeyToString(entry), assignmentCacheValueToString(entry));
40
+ }
41
+ /**
42
+ * Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
43
+ * {@link string}s.
44
+ */
45
+ entries() {
46
+ return this.delegate.entries();
47
+ }
48
+ /** Clears all entries from the cache. */
49
+ clear() {
50
+ this.delegate.clear();
51
+ }
52
+ }
53
+ //# sourceMappingURL=abstract-assignment-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-assignment-cache.js","sourceRoot":"","sources":["../../src/cache/abstract-assignment-cache.ts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AQ,CAAC,OAAO,EAAE,CAAA;IAChC,CAAC;IAED,yCAAyC;IACzC,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;CACF"}
@@ -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,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.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA"}
@@ -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,81 @@
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 class LRUCache {
15
+ constructor(capacity) {
16
+ this.capacity = capacity;
17
+ this.cache = new Map();
18
+ this.size = this.cache.size;
19
+ }
20
+ [(Symbol.toStringTag, Symbol.iterator)]() {
21
+ return this.cache[Symbol.iterator]();
22
+ }
23
+ forEach(callbackFn) {
24
+ this.cache.forEach(callbackFn);
25
+ }
26
+ entries() {
27
+ return this.cache.entries();
28
+ }
29
+ clear() {
30
+ this.cache.clear();
31
+ }
32
+ delete(key) {
33
+ return this.cache.delete(key);
34
+ }
35
+ keys() {
36
+ return this.cache.keys();
37
+ }
38
+ values() {
39
+ return this.cache.values();
40
+ }
41
+ has(key) {
42
+ return this.cache.has(key);
43
+ }
44
+ get(key) {
45
+ if (!this.has(key)) {
46
+ return undefined;
47
+ }
48
+ const value = this.cache.get(key);
49
+ if (value !== undefined) {
50
+ // the delete and set operations are used together to ensure that the most recently accessed
51
+ // or added item is always considered the "newest" in terms of access order.
52
+ // This is crucial for maintaining the correct order of elements in the cache,
53
+ // which directly impacts which item is considered the least recently used (LRU) and
54
+ // thus eligible for eviction when the cache reaches its capacity.
55
+ this.delete(key);
56
+ this.cache.set(key, value);
57
+ }
58
+ return value;
59
+ }
60
+ set(key, value) {
61
+ if (this.capacity === 0) {
62
+ return this;
63
+ }
64
+ if (this.cache.has(key)) {
65
+ this.cache.delete(key);
66
+ }
67
+ else if (this.cache.size >= this.capacity) {
68
+ // To evict the least recently used (LRU) item, we retrieve the first key in the Map.
69
+ // This is possible because the Map object in JavaScript maintains the insertion order of the keys.
70
+ // Therefore, the first key represents the oldest entry, which is the least recently used item in our cache.
71
+ // We use Map.prototype.keys().next().value to obtain this oldest key and then delete it from the cache.
72
+ const oldestKey = this.cache.keys().next().value;
73
+ if (oldestKey) {
74
+ this.delete(oldestKey);
75
+ }
76
+ }
77
+ this.cache.set(key, value);
78
+ return this;
79
+ }
80
+ }
81
+ //# 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,MAAM,OAAO,QAAQ;IAMnB,YAA+B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAL5B,UAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;QAe5C,SAAI,GAAW,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IAVW,CAAC;IAEnD,EAJC,MAAM,CAAC,WAAW,EAIlB,MAAM,CAAC,QAAQ,EAAC;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;IACtC,CAAC;IAED,OAAO,CAAC,UAA0E;QAChF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAChC,CAAC;IAID,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAA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AE,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"}
@@ -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,18 @@
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 class LRUInMemoryAssignmentCache extends AbstractAssignmentCache {
14
+ constructor(maxSize) {
15
+ super(new LRUCache(maxSize));
16
+ }
17
+ }
18
+ //# 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,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAA2B,SAAQ,uBAAiC;IAC/E,YAAY,OAAe;QACzB,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9B,CAAC;CACF"}
@@ -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,13 @@
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 class NonExpiringInMemoryAssignmentCache extends AbstractAssignmentCache {
9
+ constructor(store = new Map()) {
10
+ super(store);
11
+ }
12
+ }
13
+ //# 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,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE;;;;;GAKG;AACH,MAAM,OAAO,kCAAmC,SAAQ,uBAA4C;IAClG,YAAY,QAAQ,IAAI,GAAG,EAAkB;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/core';
2
+ /**
3
+ * Internal flags configuration for DatadogProvider.
4
+ */
5
+ export type FlagsConfiguration = {
6
+ /** @internal */
7
+ precomputed?: PrecomputedConfiguration;
8
+ };
9
+ /** @internal */
10
+ export type PrecomputedConfiguration = {
11
+ response: PrecomputedConfigurationResponse;
12
+ context?: EvaluationContext;
13
+ fetchedAt?: UnixTimestamp;
14
+ };
15
+ /** @internal */
16
+ export type FlagTypeToValue<T extends FlagValueType> = {
17
+ boolean: boolean;
18
+ string: string;
19
+ number: number;
20
+ object: JsonValue;
21
+ }[T];
22
+ /** @internal
23
+ * Timestamp in milliseconds since Unix Epoch.
24
+ */
25
+ export type UnixTimestamp = number;
26
+ /** @internal */
27
+ export type PrecomputedConfigurationResponse = {
28
+ data: {
29
+ attributes: {
30
+ /** When configuration was generated. */
31
+ createdAt: string;
32
+ flags: Record<string, PrecomputedFlag>;
33
+ };
34
+ };
35
+ };
36
+ /** @internal */
37
+ export type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
38
+ allocationKey: string;
39
+ variationKey: string;
40
+ variationType: T;
41
+ variationValue: FlagTypeToValue<T>;
42
+ reason: ResolutionReason;
43
+ doLog: boolean;
44
+ extraLogging: Record<string, unknown>;
45
+ };
46
+ /** @internal */
47
+ export type PrecomputedFlagMetadata = {
48
+ allocationKey: string;
49
+ variationType: FlagValueType;
50
+ doLog: boolean;
51
+ };
52
+ //# sourceMappingURL=configuration.d.ts.map
@@ -0,0 +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,mBAAmB,CAAA;AAEtG;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB;IAChB,WAAW,CAAC,EAAE,wBAAwB,CAAA;CACvC,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,gCAAgC,CAAA;IAC1C,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B,CAAA;AAGD,gBAAgB;AAChB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,aAAa,IAAI;IACrD,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,SAAS,CAAA;CAClB,CAAC,CAAC,CAAC,CAAA;AAEJ;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAA;AAElC,gBAAgB;AAChB,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,wCAAwC;YACxC,SAAS,EAAE,MAAM,CAAA;YACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;SACvC,CAAA;KACF,CAAA;CACF,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI;IACrE,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,CAAC,CAAA;IAChB,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IAClC,MAAM,EAAE,gBAAgB,CAAA;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,aAAa,CAAA;IAC5B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":""}
@@ -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,30 @@
1
+ export function createExposureEvent(context, details) {
2
+ var _a, _b;
3
+ // Only log if doLog flag is true
4
+ if (!((_a = details.flagMetadata) === null || _a === void 0 ? void 0 : _a.doLog)) {
5
+ return;
6
+ }
7
+ // Skip logging if allocation key or variant is missing (this should never happen)
8
+ const allocationKey = (_b = details.flagMetadata) === null || _b === void 0 ? void 0 : _b.allocationKey;
9
+ const variantKey = details.variant;
10
+ if (!allocationKey || !variantKey) {
11
+ return;
12
+ }
13
+ const { targetingKey: id = '', ...attributes } = context;
14
+ return {
15
+ allocation: {
16
+ key: allocationKey,
17
+ },
18
+ flag: {
19
+ key: details.flagKey,
20
+ },
21
+ variant: {
22
+ key: variantKey,
23
+ },
24
+ subject: {
25
+ id,
26
+ attributes,
27
+ },
28
+ };
29
+ }
30
+ //# sourceMappingURL=exposureEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=exposureEvent.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEvent.types.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './configuration';
2
+ export * from './exposureEvent';
3
+ export * from './exposureEvent.types';
4
+ export * from './wire';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
1
+ export * from './configuration';
2
+ export * from './exposureEvent';
3
+ export * from './exposureEvent.types';
4
+ export * from './wire';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","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"}
@@ -0,0 +1,12 @@
1
+ import type { FlagsConfiguration } from './configuration';
2
+ /**
3
+ * Create configuration from a string created with `configurationToString`.
4
+ */
5
+ export declare function configurationFromString(s: string): FlagsConfiguration;
6
+ /**
7
+ * Serialize configuration to string that can be deserialized with
8
+ * `configurationFromString`. The serialized string format is
9
+ * unspecified.
10
+ */
11
+ export declare function configurationToString(configuration: FlagsConfiguration): string;
12
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAA;AAWxE;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAqBrE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,kBAAkB,GAAG,MAAM,CAa/E"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Create configuration from a string created with `configurationToString`.
3
+ */
4
+ export function configurationFromString(s) {
5
+ try {
6
+ const wire = JSON.parse(s);
7
+ if (wire.version !== 1) {
8
+ // Unknown version
9
+ return {};
10
+ }
11
+ const configuration = {};
12
+ if (wire.precomputed) {
13
+ configuration.precomputed = {
14
+ ...wire.precomputed,
15
+ response: JSON.parse(wire.precomputed.response),
16
+ };
17
+ }
18
+ return configuration;
19
+ }
20
+ catch (_a) {
21
+ return {};
22
+ }
23
+ }
24
+ /**
25
+ * Serialize configuration to string that can be deserialized with
26
+ * `configurationFromString`. The serialized string format is
27
+ * unspecified.
28
+ */
29
+ export function configurationToString(configuration) {
30
+ const wire = {
31
+ version: 1,
32
+ };
33
+ if (configuration.precomputed) {
34
+ wire.precomputed = {
35
+ ...configuration.precomputed,
36
+ response: JSON.stringify(configuration.precomputed),
37
+ };
38
+ }
39
+ return JSON.stringify(wire);
40
+ }
41
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAS;IAC/C,IAAI,CAAC;QACH,MAAM,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAE7C,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,kBAAkB;YAClB,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,aAAa,GAAuB,EAAE,CAAA;QAC5C,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,aAAa,CAAC,WAAW,GAAG;gBAC1B,GAAG,IAAI,CAAC,WAAW;gBACnB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;aAChD,CAAA;QACH,CAAC;QAED,OAAO,aAAa,CAAA;IACtB,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAiC;IACrE,MAAM,IAAI,GAAsB;QAC9B,OAAO,EAAE,CAAC;KACX,CAAA;IAED,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG;YACjB,GAAG,aAAa,CAAC,WAAW;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC;SACpD,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './cache';
2
+ export * from './configuration';
3
+ export * from './obfuscation';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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/esm/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './cache';
2
+ export * from './configuration';
3
+ export * from './obfuscation';
4
+ // Build environment placeholder for testing
5
+ const _SDK_VERSION = "dev";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;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,16 @@
1
+ import SparkMD5 from 'spark-md5';
2
+ export function getMD5Hash(input, salt = '') {
3
+ return new SparkMD5().append(salt).append(input).end();
4
+ }
5
+ /**
6
+ * Builds a storage key suffix from an API key.
7
+ * @param apiKey - The API key to build the suffix from
8
+ * @returns A string suffix for storage keys
9
+ * @public
10
+ */
11
+ export function buildStorageKeySuffix(apiKey) {
12
+ // Note that we hash the API key and use the first 16 characters of the digest.
13
+ const hashed = getMD5Hash(apiKey);
14
+ return hashed.slice(0, 16);
15
+ }
16
+ //# sourceMappingURL=obfuscation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/flagging-core",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-preview.11",
4
4
  "description": "Runtime-agnostic flag-evaluation logic for Datadog Flagging",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,6 +8,11 @@
8
8
  "url": "https://github.com/DataDog/openfeature-js-client.git",
9
9
  "directory": "packages/core"
10
10
  },
11
+ "files": [
12
+ "cjs/",
13
+ "esm/",
14
+ "*.d.ts"
15
+ ],
11
16
  "publishConfig": {
12
17
  "access": "public",
13
18
  "registry": "https://registry.npmjs.org/"
@@ -28,9 +33,9 @@
28
33
  },
29
34
  "devDependencies": {
30
35
  "@openfeature/core": "^1.8.1",
31
- "@openfeature/web-sdk": "^1.5.0",
32
36
  "@types/jest": "^29.4.0",
33
- "@types/node": "^20.0.0",
37
+ "@types/node": "^18.0.0",
38
+ "@types/spark-md5": "^3.0.5",
34
39
  "jest": "^30.0.4",
35
40
  "npm-run-all": "^4.1.5",
36
41
  "ts-jest": "^29.4.0",
@@ -38,7 +43,9 @@
38
43
  "typescript": "^5.5.0"
39
44
  },
40
45
  "peerDependencies": {
41
- "@openfeature/core": "^1.8.1",
42
- "@openfeature/web-sdk": "^1.5.0"
46
+ "@openfeature/core": "^1.8.1"
47
+ },
48
+ "dependencies": {
49
+ "spark-md5": "^3.0.2"
43
50
  }
44
51
  }
package/jest.config.js DELETED
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- transform: {
5
- '^.+\\.ts$': [
6
- 'ts-jest',
7
- {
8
- tsconfig: 'tsconfig.test.json',
9
- },
10
- ],
11
- },
12
- testMatch: ['**/*.spec.ts', '**/*.test.ts'],
13
- moduleFileExtensions: ['ts', 'js', 'json'],
14
- collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'],
15
- }