@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 +17 -0
- package/dist/cjs/api/data/LDEvaluationReason.d.ts +11 -0
- package/dist/cjs/api/data/LDEvaluationReason.d.ts.map +1 -1
- package/dist/cjs/api/platform/Filesystem.d.ts +31 -1
- package/dist/cjs/api/platform/Filesystem.d.ts.map +1 -1
- package/dist/cjs/index.cjs +20 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/internal/evaluation/EventFactoryBase.d.ts +1 -0
- package/dist/cjs/internal/evaluation/EventFactoryBase.d.ts.map +1 -1
- package/dist/cjs/internal/events/EventProcessor.d.ts.map +1 -1
- package/dist/cjs/internal/events/InputEvalEvent.d.ts +7 -1
- package/dist/cjs/internal/events/InputEvalEvent.d.ts.map +1 -1
- package/dist/cjs/internal/events/LDEventSummarizer.d.ts.map +1 -1
- package/dist/esm/api/data/LDEvaluationReason.d.ts +11 -0
- package/dist/esm/api/data/LDEvaluationReason.d.ts.map +1 -1
- package/dist/esm/api/platform/Filesystem.d.ts +31 -1
- package/dist/esm/api/platform/Filesystem.d.ts.map +1 -1
- package/dist/esm/index.mjs +20 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +1 -0
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts.map +1 -1
- package/dist/esm/internal/events/EventProcessor.d.ts.map +1 -1
- package/dist/esm/internal/events/InputEvalEvent.d.ts +7 -1
- package/dist/esm/internal/events/InputEvalEvent.d.ts.map +1 -1
- package/dist/esm/internal/events/LDEventSummarizer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2738,12 +2738,13 @@ function isMigration(u) {
|
|
|
2738
2738
|
* @internal
|
|
2739
2739
|
*/
|
|
2740
2740
|
class SummaryCounter {
|
|
2741
|
-
constructor(count, key, value, defValue, version, variation) {
|
|
2741
|
+
constructor(count, key, value, defValue, version, variation, overrideAffected) {
|
|
2742
2742
|
this.count = count;
|
|
2743
2743
|
this.key = key;
|
|
2744
2744
|
this.value = value;
|
|
2745
2745
|
this.version = version;
|
|
2746
2746
|
this.variation = variation;
|
|
2747
|
+
this.overrideAffected = overrideAffected;
|
|
2747
2748
|
this.default = defValue;
|
|
2748
2749
|
}
|
|
2749
2750
|
increment() {
|
|
@@ -2751,8 +2752,10 @@ class SummaryCounter {
|
|
|
2751
2752
|
}
|
|
2752
2753
|
}
|
|
2753
2754
|
|
|
2755
|
+
// The override marker is part of the key, so override-affected and other evaluations of the same
|
|
2756
|
+
// flag, variation, and version accumulate into separate counters.
|
|
2754
2757
|
function counterKey(event) {
|
|
2755
|
-
return `${event.key}:${event.variation !== null && event.variation !== undefined ? event.variation : ''}:${event.version !== null && event.version !== undefined ? event.version : ''}`;
|
|
2758
|
+
return `${event.key}:${event.variation !== null && event.variation !== undefined ? event.variation : ''}:${event.version !== null && event.version !== undefined ? event.version : ''}:${event.overrideAffected ? 'overrideAffected' : ''}`;
|
|
2756
2759
|
}
|
|
2757
2760
|
/**
|
|
2758
2761
|
* @internal
|
|
@@ -2783,7 +2786,7 @@ class EventSummarizer {
|
|
|
2783
2786
|
counter.increment();
|
|
2784
2787
|
}
|
|
2785
2788
|
else {
|
|
2786
|
-
this._counters[countKey] = new SummaryCounter(1, event.key, event.value, event.default, event.version, event.variation);
|
|
2789
|
+
this._counters[countKey] = new SummaryCounter(1, event.key, event.value, event.default, event.version, event.variation, event.overrideAffected);
|
|
2787
2790
|
}
|
|
2788
2791
|
if (this._startDate === 0 || event.creationDate < this._startDate) {
|
|
2789
2792
|
this._startDate = event.creationDate;
|
|
@@ -2817,6 +2820,10 @@ class EventSummarizer {
|
|
|
2817
2820
|
else {
|
|
2818
2821
|
counterOut.unknown = true;
|
|
2819
2822
|
}
|
|
2823
|
+
if (counter.overrideAffected) {
|
|
2824
|
+
// The marker is present only when true, like the unknown marker.
|
|
2825
|
+
counterOut.overrideAffected = true;
|
|
2826
|
+
}
|
|
2820
2827
|
flagSummary.counters.push(counterOut);
|
|
2821
2828
|
return acc;
|
|
2822
2829
|
}, {});
|
|
@@ -3021,8 +3028,11 @@ class EventProcessor {
|
|
|
3021
3028
|
}
|
|
3022
3029
|
this._summarizer.summarizeEvent(inputEvent);
|
|
3023
3030
|
const isFeatureEvent = isFeature(inputEvent);
|
|
3024
|
-
|
|
3025
|
-
|
|
3031
|
+
// An override-affected evaluation appears only in the summary counters. It produces no
|
|
3032
|
+
// individual feature event and no debug event, even when the flag requests them.
|
|
3033
|
+
const overrideAffected = isFeatureEvent && !!inputEvent.overrideAffected;
|
|
3034
|
+
const addFullEvent = (isFeatureEvent && inputEvent.trackEvents && !overrideAffected) || !isFeatureEvent;
|
|
3035
|
+
const addDebugEvent = !overrideAffected && this._shouldDebugEvent(inputEvent);
|
|
3026
3036
|
const isIdentifyEvent = isIdentify(inputEvent);
|
|
3027
3037
|
const shouldNotDeduplicate = this._contextDeduplicator?.processContext(inputEvent.context);
|
|
3028
3038
|
// If there is no cache, then it will never be in the cache.
|
|
@@ -3188,7 +3198,7 @@ class InputCustomEvent {
|
|
|
3188
3198
|
|
|
3189
3199
|
class InputEvalEvent {
|
|
3190
3200
|
constructor(withReasons, context, key, value, defValue, // default is a reserved keyword in this context.
|
|
3191
|
-
version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1) {
|
|
3201
|
+
version, variation, trackEvents, prereqOf, reason, debugEventsUntilDate, excludeFromSummaries, samplingRatio = 1, overrideAffected) {
|
|
3192
3202
|
this.withReasons = withReasons;
|
|
3193
3203
|
this.context = context;
|
|
3194
3204
|
this.key = key;
|
|
@@ -3218,6 +3228,9 @@ class InputEvalEvent {
|
|
|
3218
3228
|
if (excludeFromSummaries !== undefined) {
|
|
3219
3229
|
this.excludeFromSummaries = excludeFromSummaries;
|
|
3220
3230
|
}
|
|
3231
|
+
if (overrideAffected !== undefined) {
|
|
3232
|
+
this.overrideAffected = overrideAffected;
|
|
3233
|
+
}
|
|
3221
3234
|
}
|
|
3222
3235
|
}
|
|
3223
3236
|
|
|
@@ -3245,7 +3258,7 @@ class EventFactoryBase {
|
|
|
3245
3258
|
evalEvent(e) {
|
|
3246
3259
|
return new InputEvalEvent(this._withReasons, e.context, e.flagKey, e.value, e.defaultVal, e.version,
|
|
3247
3260
|
// Exclude null as a possibility.
|
|
3248
|
-
e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this._withReasons || e.addExperimentData ? e.reason : undefined, e.debugEventsUntilDate, e.excludeFromSummaries, e.samplingRatio);
|
|
3261
|
+
e.variation ?? undefined, e.trackEvents || e.addExperimentData, e.prereqOfFlagKey, this._withReasons || e.addExperimentData ? e.reason : undefined, e.debugEventsUntilDate, e.excludeFromSummaries, e.samplingRatio, e.overrideAffected);
|
|
3249
3262
|
}
|
|
3250
3263
|
unknownFlagEvent(key, defVal, context) {
|
|
3251
3264
|
return new InputEvalEvent(this._withReasons, context, key, defVal, defVal,
|