@launchdarkly/js-sdk-common 2.30.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to `@launchdarkly/js-sdk-common` will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [2.31.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.30.0...js-sdk-common-v2.31.0) (2026-10-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * Add experimental support for file-based overrides. ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
11
+ * Add optional file stats, watch error reporting, and the changed entry name to the platform filesystem interface ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Coalesce bursts of file change notifications into one file data reload ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
17
+ * Detect rename-based writes and recreated files in the file data source by watching the containing directories ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
18
+ * Re-establish the file data watch when a watched directory is deleted and created again ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
19
+ * Report file data read and processing failures through the error handler instead of an unhandled promise rejection ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
20
+ * Retry a failed file data reload and keep the last good data in effect ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
21
+
5
22
  ## [2.30.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.29.0...js-sdk-common-v2.30.0) (2026-10-14)
6
23
 
7
24
 
@@ -53,5 +53,16 @@ export interface LDEvaluationReason {
53
53
  * instance due to a database error.
54
54
  */
55
55
  bigSegmentsStatus?: 'HEALTHY' | 'STALE' | 'NOT_CONFIGURED' | 'STORE_ERROR';
56
+ /**
57
+ * True when an override affected the evaluation, directly or transitively.
58
+ *
59
+ * This is the case when the evaluated flag came from the SDK's override store, or when a
60
+ * prerequisite flag at any depth or a segment read during the evaluation came from that store.
61
+ * Otherwise it is false or undefined. In the JSON representation of the reason the property is
62
+ * present only when it is true.
63
+ *
64
+ * @experimental Flag overrides are currently experimental and subject to change.
65
+ */
66
+ overrideAffected?: boolean;
56
67
  }
57
68
  //# sourceMappingURL=LDEvaluationReason.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LDEvaluationReason.d.ts","sourceRoot":"","sources":["../../../src/api/data/LDEvaluationReason.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,gBAAgB,GAAG,aAAa,CAAC;CAC5E"}
1
+ {"version":3,"file":"LDEvaluationReason.d.ts","sourceRoot":"","sources":["../../../src/api/data/LDEvaluationReason.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAE3E;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -4,6 +4,20 @@ export interface WatchHandle {
4
4
  */
5
5
  close(): void;
6
6
  }
7
+ /**
8
+ * Metadata of a file that a component can compare between two observations to detect a
9
+ * change.
10
+ */
11
+ export interface FileStats {
12
+ /**
13
+ * The time, in ms since POSIX epoch, that the file was last modified.
14
+ */
15
+ timestamp: number;
16
+ /**
17
+ * The size of the file in bytes.
18
+ */
19
+ size: number;
20
+ }
7
21
  /**
8
22
  * Interface for doing filesystem operations on the platform.
9
23
  */
@@ -24,6 +38,16 @@ export interface Filesystem {
24
38
  * rejected if the operation fails.
25
39
  */
26
40
  readFile(path: string): Promise<string>;
41
+ /**
42
+ * Get the metadata of a file. Components use it to detect that a file changed, appeared, or
43
+ * disappeared.
44
+ *
45
+ * @param path The path of the file.
46
+ *
47
+ * @returns A promise which will resolve to the file metadata, or to undefined when the file
48
+ * does not exist. The promise is rejected when the operation fails for another reason.
49
+ */
50
+ getFileStats?(path: string): Promise<FileStats | undefined>;
27
51
  /**
28
52
  * Watch for changes to the specified path.
29
53
  *
@@ -31,10 +55,16 @@ export interface Filesystem {
31
55
  * it should not keep the containing process running as long as it is
32
56
  * executing. For node this means setting the persistent option to false.
33
57
  *
58
+ * When the watch itself fails, the implementation should invoke the callback with the event
59
+ * type `error` instead of raising, so that the owner of the watch can set it up again.
60
+ *
34
61
  * @param path The path to watch.
62
+ * @param callback Receives the event type, the watched path, and, when the platform reports
63
+ * it, the name of the entry within the watched path that changed. The name is undefined when
64
+ * the platform does not report it.
35
65
  *
36
66
  * @returns An async iterator that watches for changes to `path`.
37
67
  */
38
- watch(path: string, callback: (eventType: string, filename: string) => void): WatchHandle;
68
+ watch(path: string, callback: (eventType: string, filename: string, changedName?: string) => void): WatchHandle;
39
69
  }
40
70
  //# sourceMappingURL=Filesystem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Filesystem.d.ts","sourceRoot":"","sources":["../../../src/api/platform/Filesystem.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW,CAAC;CAC3F"}
1
+ {"version":3,"file":"Filesystem.d.ts","sourceRoot":"","sources":["../../../src/api/platform/Filesystem.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC;;;;;;;;OAQG;IACH,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAE5D;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,GAC5E,WAAW,CAAC;CAChB"}
@@ -2740,12 +2740,13 @@ function isMigration(u) {
2740
2740
  * @internal
2741
2741
  */
2742
2742
  class SummaryCounter {
2743
- constructor(count, key, value, defValue, version, variation) {
2743
+ constructor(count, key, value, defValue, version, variation, overrideAffected) {
2744
2744
  this.count = count;
2745
2745
  this.key = key;
2746
2746
  this.value = value;
2747
2747
  this.version = version;
2748
2748
  this.variation = variation;
2749
+ this.overrideAffected = overrideAffected;
2749
2750
  this.default = defValue;
2750
2751
  }
2751
2752
  increment() {
@@ -2753,8 +2754,10 @@ class SummaryCounter {
2753
2754
  }
2754
2755
  }
2755
2756
 
2757
+ // The override marker is part of the key, so override-affected and other evaluations of the same
2758
+ // flag, variation, and version accumulate into separate counters.
2756
2759
  function counterKey(event) {
2757
- return `${event.key}:${event.variation !== null && event.variation !== undefined ? event.variation : ''}:${event.version !== null && event.version !== undefined ? event.version : ''}`;
2760
+ return `${event.key}:${event.variation !== null && event.variation !== undefined ? event.variation : ''}:${event.version !== null && event.version !== undefined ? event.version : ''}:${event.overrideAffected ? 'overrideAffected' : ''}`;
2758
2761
  }
2759
2762
  /**
2760
2763
  * @internal
@@ -2785,7 +2788,7 @@ class EventSummarizer {
2785
2788
  counter.increment();
2786
2789
  }
2787
2790
  else {
2788
- this._counters[countKey] = new SummaryCounter(1, event.key, event.value, event.default, event.version, event.variation);
2791
+ this._counters[countKey] = new SummaryCounter(1, event.key, event.value, event.default, event.version, event.variation, event.overrideAffected);
2789
2792
  }
2790
2793
  if (this._startDate === 0 || event.creationDate < this._startDate) {
2791
2794
  this._startDate = event.creationDate;
@@ -2819,6 +2822,10 @@ class EventSummarizer {
2819
2822
  else {
2820
2823
  counterOut.unknown = true;
2821
2824
  }
2825
+ if (counter.overrideAffected) {
2826
+ // The marker is present only when true, like the unknown marker.
2827
+ counterOut.overrideAffected = true;
2828
+ }
2822
2829
  flagSummary.counters.push(counterOut);
2823
2830
  return acc;
2824
2831
  }, {});
@@ -3023,8 +3030,11 @@ class EventProcessor {
3023
3030
  }
3024
3031
  this._summarizer.summarizeEvent(inputEvent);
3025
3032
  const isFeatureEvent = isFeature(inputEvent);
3026
- const addFullEvent = (isFeatureEvent && inputEvent.trackEvents) || !isFeatureEvent;
3027
- const addDebugEvent = this._shouldDebugEvent(inputEvent);
3033
+ // An override-affected evaluation appears only in the summary counters. It produces no
3034
+ // individual feature event and no debug event, even when the flag requests them.
3035
+ const overrideAffected = isFeatureEvent && !!inputEvent.overrideAffected;
3036
+ const addFullEvent = (isFeatureEvent && inputEvent.trackEvents && !overrideAffected) || !isFeatureEvent;
3037
+ const addDebugEvent = !overrideAffected && this._shouldDebugEvent(inputEvent);
3028
3038
  const isIdentifyEvent = isIdentify(inputEvent);
3029
3039
  const shouldNotDeduplicate = this._contextDeduplicator?.processContext(inputEvent.context);
3030
3040
  // If there is no cache, then it will never be in the cache.
@@ -3190,7 +3200,7 @@ class InputCustomEvent {
3190
3200
 
3191
3201
  class InputEvalEvent {
3192
3202
  constructor(withReasons, context, key, value, defValue, // default is a reserved keyword in this context.
3193
- version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1) {
3203
+ version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1, overrideAffected) {
3194
3204
  this.withReasons = withReasons;
3195
3205
  this.context = context;
3196
3206
  this.key = key;
@@ -3220,6 +3230,9 @@ class InputEvalEvent {
3220
3230
  if (excludeFromSummaries !== undefined) {
3221
3231
  this.excludeFromSummaries = excludeFromSummaries;
3222
3232
  }
3233
+ if (overrideAffected !== undefined) {
3234
+ this.overrideAffected = overrideAffected;
3235
+ }
3223
3236
  }
3224
3237
  }
3225
3238
 
@@ -3247,7 +3260,7 @@ class EventFactoryBase {
3247
3260
  evalEvent(e) {
3248
3261
  return new InputEvalEvent(this._withReasons, e.context, e.flagKey, e.value, e.defaultVal, e.version,
3249
3262
  // Exclude null as a possibility.
3250
- e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this._withReasons || e.addExperimentData ? e.reason : undefined, e.debugEventsUntilDate, e.excludeFromSummaries, e.samplingRatio);
3263
+ e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this._withReasons || e.addExperimentData ? e.reason : undefined, e.debugEventsUntilDate, e.excludeFromSummaries, e.samplingRatio, e.overrideAffected);
3251
3264
  }
3252
3265
  unknownFlagEvent(key, defVal, context) {
3253
3266
  return new InputEvalEvent(this._withReasons, context, key, defVal, defVal,