@launchdarkly/js-sdk-common 2.30.0 → 2.32.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 +32 -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 +105 -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/cjs/internal/fdv2/protocolHandler.d.ts.map +1 -1
- package/dist/cjs/internal/fetch/followRedirects.d.ts +34 -0
- package/dist/cjs/internal/fetch/followRedirects.d.ts.map +1 -0
- package/dist/cjs/internal/fetch/index.d.ts +1 -0
- package/dist/cjs/internal/fetch/index.d.ts.map +1 -1
- package/dist/esm/AttributeReference.d.ts +1 -1
- package/dist/esm/Context.d.ts +2 -2
- package/dist/esm/ContextFilter.d.ts +2 -2
- package/dist/esm/api/context/LDContext.d.ts +3 -3
- package/dist/esm/api/context/LDContextCommon.d.ts +1 -1
- package/dist/esm/api/context/LDMultiKindContext.d.ts +1 -1
- package/dist/esm/api/context/LDSingleKindContext.d.ts +1 -1
- package/dist/esm/api/context/index.d.ts +6 -6
- package/dist/esm/api/data/LDEvaluationDetail.d.ts +2 -2
- 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/data/LDFlagSet.d.ts +1 -1
- package/dist/esm/api/data/index.d.ts +4 -4
- package/dist/esm/api/index.d.ts +7 -7
- package/dist/esm/api/integrations/index.d.ts +1 -1
- package/dist/esm/api/logging/BasicLoggerOptions.d.ts +1 -1
- package/dist/esm/api/logging/index.d.ts +3 -3
- package/dist/esm/api/options/LDClientContext.d.ts +2 -2
- package/dist/esm/api/options/index.d.ts +1 -1
- package/dist/esm/api/platform/EventSource.d.ts +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/api/platform/Info.d.ts +1 -1
- package/dist/esm/api/platform/Platform.d.ts +6 -6
- package/dist/esm/api/platform/Requests.d.ts +1 -1
- package/dist/esm/api/platform/index.d.ts +9 -9
- package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts +1 -1
- package/dist/esm/api/subsystem/DataSystem/index.d.ts +1 -1
- package/dist/esm/api/subsystem/LDContextDeduplicator.d.ts +1 -1
- package/dist/esm/api/subsystem/LDEventProcessor.d.ts +1 -1
- package/dist/esm/api/subsystem/index.d.ts +5 -5
- package/dist/esm/datasource/CompositeDataSource.d.ts +3 -3
- package/dist/esm/datasource/errors.d.ts +1 -1
- package/dist/esm/datasource/index.d.ts +5 -5
- package/dist/esm/datasource/retry/RetryState.d.ts +3 -3
- package/dist/esm/datasource/retry/index.d.ts +2 -2
- package/dist/esm/index.d.ts +11 -11
- package/dist/esm/index.mjs +105 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/context/index.d.ts +1 -1
- package/dist/esm/internal/diagnostics/DiagnosticsManager.d.ts +2 -2
- package/dist/esm/internal/diagnostics/index.d.ts +1 -1
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +4 -3
- package/dist/esm/internal/evaluation/EventFactoryBase.d.ts.map +1 -1
- package/dist/esm/internal/evaluation/index.d.ts +2 -2
- package/dist/esm/internal/events/EventProcessor.d.ts +6 -6
- package/dist/esm/internal/events/EventProcessor.d.ts.map +1 -1
- package/dist/esm/internal/events/EventSender.d.ts +3 -3
- package/dist/esm/internal/events/InputClickEvent.d.ts +1 -1
- package/dist/esm/internal/events/InputCustomEvent.d.ts +1 -1
- package/dist/esm/internal/events/InputEvalEvent.d.ts +9 -3
- package/dist/esm/internal/events/InputEvalEvent.d.ts.map +1 -1
- package/dist/esm/internal/events/InputEvent.d.ts +6 -6
- package/dist/esm/internal/events/InputEventBase.d.ts +1 -1
- package/dist/esm/internal/events/InputIdentifyEvent.d.ts +1 -1
- package/dist/esm/internal/events/InputMigrationEvent.d.ts +1 -1
- package/dist/esm/internal/events/InputPageViewEvent.d.ts +1 -1
- package/dist/esm/internal/events/LDEventSummarizer.d.ts +1 -1
- package/dist/esm/internal/events/LDEventSummarizer.d.ts.map +1 -1
- package/dist/esm/internal/events/MultiEventSummarizer.d.ts +4 -4
- package/dist/esm/internal/events/NullEventProcessor.d.ts +1 -1
- package/dist/esm/internal/events/guards.d.ts +4 -4
- package/dist/esm/internal/events/index.d.ts +10 -10
- package/dist/esm/internal/fdv2/FDv1PayloadAdaptor.d.ts +1 -1
- package/dist/esm/internal/fdv2/index.d.ts +8 -8
- package/dist/esm/internal/fdv2/payloadProcessor.d.ts +4 -4
- package/dist/esm/internal/fdv2/payloadStreamReader.d.ts +3 -3
- package/dist/esm/internal/fdv2/protocolHandler.d.ts +2 -2
- package/dist/esm/internal/fdv2/protocolHandler.d.ts.map +1 -1
- package/dist/esm/internal/fetch/StreamingResponse.d.ts +1 -1
- package/dist/esm/internal/fetch/followRedirects.d.ts +34 -0
- package/dist/esm/internal/fetch/followRedirects.d.ts.map +1 -0
- package/dist/esm/internal/fetch/index.d.ts +3 -2
- package/dist/esm/internal/fetch/index.d.ts.map +1 -1
- package/dist/esm/internal/fetch/toRequestInit.d.ts +1 -1
- package/dist/esm/internal/index.d.ts +9 -9
- package/dist/esm/internal/json/index.d.ts +1 -1
- package/dist/esm/internal/metadata/index.d.ts +1 -1
- package/dist/esm/internal/plugins/index.d.ts +3 -3
- package/dist/esm/internal/plugins/safeGetHooks.d.ts +2 -2
- package/dist/esm/internal/plugins/safeGetName.d.ts +2 -2
- package/dist/esm/internal/plugins/safeRegisterPlugins.d.ts +2 -2
- package/dist/esm/logging/BasicLogger.d.ts +1 -1
- package/dist/esm/logging/SafeLogger.d.ts +1 -1
- package/dist/esm/logging/createSafeLogger.d.ts +3 -3
- package/dist/esm/logging/index.d.ts +3 -3
- package/dist/esm/options/ApplicationTags.d.ts +1 -1
- package/dist/esm/options/ClientContext.d.ts +3 -3
- package/dist/esm/options/index.d.ts +4 -4
- package/dist/esm/utils/cancelableTimedPromise.d.ts +1 -1
- package/dist/esm/utils/http.d.ts +2 -2
- package/dist/esm/utils/index.d.ts +12 -12
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
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.32.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.31.0...js-sdk-common-v2.32.0) (2026-10-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Migrate the Node.js server and client SDKs to @launchdarkly/eventsource through the platform fetch ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
|
|
11
|
+
* Verify TLS certificates on streaming connections by default; a stream served by a private CA now requires tlsParams ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* Allow polling and event delivery to connect through a proxy when a private CA is configured ([10b57b0](https://github.com/launchdarkly/js-core/commit/10b57b01ce348b216fd98e515740bc5d50830017))
|
|
17
|
+
* Ignore FDv2 put-object and delete-object events with unsupported kinds ([#2109](https://github.com/launchdarkly/js-core/issues/2109)) ([2729c04](https://github.com/launchdarkly/js-core/commit/2729c046493ba4c84ce0f4abf5be0b369d86c68c))
|
|
18
|
+
* Resolve types under node16/nodenext module resolution ([#2115](https://github.com/launchdarkly/js-core/issues/2115)) ([ca1613c](https://github.com/launchdarkly/js-core/commit/ca1613c20130b9308bafb8c98e0843d8d92fee01))
|
|
19
|
+
|
|
20
|
+
## [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)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* Add experimental support for file-based overrides. ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
|
|
26
|
+
* 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))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* Coalesce bursts of file change notifications into one file data reload ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
|
|
32
|
+
* 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))
|
|
33
|
+
* Re-establish the file data watch when a watched directory is deleted and created again ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
|
|
34
|
+
* 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))
|
|
35
|
+
* Retry a failed file data reload and keep the last good data in effect ([9c0effe](https://github.com/launchdarkly/js-core/commit/9c0effe9d614ce41cf72a3254e25822c32d9d2f2))
|
|
36
|
+
|
|
5
37
|
## [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
38
|
|
|
7
39
|
|
|
@@ -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;
|
|
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
|
|
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/cjs/index.cjs
CHANGED
|
@@ -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
|
-
|
|
3027
|
-
|
|
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,
|
|
@@ -3387,6 +3400,11 @@ function createProtocolHandler(objProcessors, logger) {
|
|
|
3387
3400
|
let protocolState = 'inactive';
|
|
3388
3401
|
let tempType = 'partial';
|
|
3389
3402
|
let tempUpdates = [];
|
|
3403
|
+
// Only kinds with a registered processor are supported. An own-property check keeps
|
|
3404
|
+
// kinds such as 'constructor' from resolving to inherited members.
|
|
3405
|
+
function isSupportedKind(kind) {
|
|
3406
|
+
return Object.prototype.hasOwnProperty.call(objProcessors, kind);
|
|
3407
|
+
}
|
|
3390
3408
|
function processObj(kind, jsonObj) {
|
|
3391
3409
|
return objProcessors[kind]?.(jsonObj);
|
|
3392
3410
|
}
|
|
@@ -3457,6 +3475,12 @@ function createProtocolHandler(objProcessors, logger) {
|
|
|
3457
3475
|
logger?.warn(`Ignoring put-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
|
|
3458
3476
|
return ACTION_NONE;
|
|
3459
3477
|
}
|
|
3478
|
+
// Objects of unsupported kinds are dropped silently so the protocol can add new kinds
|
|
3479
|
+
// without disrupting older SDKs.
|
|
3480
|
+
if (!isSupportedKind(data.kind)) {
|
|
3481
|
+
logger?.debug(`Ignoring put-object with unsupported kind: '${data.kind}'`);
|
|
3482
|
+
return ACTION_NONE;
|
|
3483
|
+
}
|
|
3460
3484
|
const obj = processObj(data.kind, data.object);
|
|
3461
3485
|
if (!obj) {
|
|
3462
3486
|
logger?.warn(`Unable to process object for kind: '${data.kind}'`);
|
|
@@ -3479,6 +3503,10 @@ function createProtocolHandler(objProcessors, logger) {
|
|
|
3479
3503
|
logger?.warn(`Ignoring delete-object with missing fields: kind=${data.kind}, key=${data.key}, version=${data.version}`);
|
|
3480
3504
|
return ACTION_NONE;
|
|
3481
3505
|
}
|
|
3506
|
+
if (!isSupportedKind(data.kind)) {
|
|
3507
|
+
logger?.debug(`Ignoring delete-object with unsupported kind: '${data.kind}'`);
|
|
3508
|
+
return ACTION_NONE;
|
|
3509
|
+
}
|
|
3482
3510
|
tempUpdates.push({
|
|
3483
3511
|
kind: data.kind,
|
|
3484
3512
|
key: data.key,
|
|
@@ -3661,6 +3689,74 @@ class PayloadStreamReader {
|
|
|
3661
3689
|
}
|
|
3662
3690
|
}
|
|
3663
3691
|
|
|
3692
|
+
/**
|
|
3693
|
+
* The most redirect hops one streaming request follows. When a chain exceeds the cap, the last
|
|
3694
|
+
* redirect response goes to the caller as an ordinary non-200 response. The caller's error
|
|
3695
|
+
* handling decides whether to retry.
|
|
3696
|
+
*/
|
|
3697
|
+
const MAX_STREAMING_REDIRECT_HOPS = 5;
|
|
3698
|
+
/**
|
|
3699
|
+
* Resolves the target of a redirect response. The target can be relative, and it resolves
|
|
3700
|
+
* against the URL of the redirected request. Only an `http:` or `https:` target can carry
|
|
3701
|
+
* the stream; any other scheme, a missing or empty `Location`, and an unparsable value all
|
|
3702
|
+
* resolve to `undefined`, and the redirect response then goes to the caller unfollowed.
|
|
3703
|
+
*/
|
|
3704
|
+
function redirectTarget(headers, baseUrl) {
|
|
3705
|
+
const raw = headers.location;
|
|
3706
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
3707
|
+
if (typeof value !== 'string' || value === '') {
|
|
3708
|
+
return undefined;
|
|
3709
|
+
}
|
|
3710
|
+
try {
|
|
3711
|
+
const resolved = new URL(value, baseUrl);
|
|
3712
|
+
if (resolved.protocol !== 'http:' && resolved.protocol !== 'https:') {
|
|
3713
|
+
return undefined;
|
|
3714
|
+
}
|
|
3715
|
+
return resolved.href;
|
|
3716
|
+
}
|
|
3717
|
+
catch {
|
|
3718
|
+
return undefined;
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
/**
|
|
3722
|
+
* Issues a streaming request and follows up to {@link MAX_STREAMING_REDIRECT_HOPS} hops of
|
|
3723
|
+
* `301` and `307` redirects. Each hop calls `doRequest` again with the target URL, so the
|
|
3724
|
+
* request carries the same method, body, and headers to each target, the `Authorization`
|
|
3725
|
+
* header included. A `302` and every other status return to the caller unfollowed.
|
|
3726
|
+
*
|
|
3727
|
+
* The loop holds no state across calls. A reconnect starts from the original URL again and
|
|
3728
|
+
* re-follows the chain.
|
|
3729
|
+
*
|
|
3730
|
+
* @param url The URL of the initial request.
|
|
3731
|
+
* @param doRequest Issues one request and resolves with its response. The caller builds the
|
|
3732
|
+
* options inside it from the given URL, so each hop gets options for its own target.
|
|
3733
|
+
*/
|
|
3734
|
+
async function followStreamingRedirects(url, doRequest) {
|
|
3735
|
+
let currentUrl = url;
|
|
3736
|
+
let res = await doRequest(currentUrl);
|
|
3737
|
+
let hops = 0;
|
|
3738
|
+
while ((res.statusCode === 301 || res.statusCode === 307) && hops < MAX_STREAMING_REDIRECT_HOPS) {
|
|
3739
|
+
const target = redirectTarget(res.headers, currentUrl);
|
|
3740
|
+
if (target === undefined) {
|
|
3741
|
+
return res;
|
|
3742
|
+
}
|
|
3743
|
+
hops += 1;
|
|
3744
|
+
// The destroy releases the skipped redirect response and its connection at once, so a
|
|
3745
|
+
// redirect body that never ends cannot hold a socket for the life of the attempt.
|
|
3746
|
+
try {
|
|
3747
|
+
res.destroy?.();
|
|
3748
|
+
}
|
|
3749
|
+
catch {
|
|
3750
|
+
// A throwing destroy has nothing left to release.
|
|
3751
|
+
}
|
|
3752
|
+
currentUrl = target;
|
|
3753
|
+
// The hops are sequential. The next request cannot start until this response arrives.
|
|
3754
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3755
|
+
res = await doRequest(currentUrl);
|
|
3756
|
+
}
|
|
3757
|
+
return res;
|
|
3758
|
+
}
|
|
3759
|
+
|
|
3664
3760
|
/**
|
|
3665
3761
|
* Wraps the raw headers in the fetch `Headers` shape. Lookups are case-insensitive.
|
|
3666
3762
|
* Multi-value headers are joined with ", ", names that differ only by case merge into one
|
|
@@ -3861,12 +3957,14 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3861
3957
|
InputCustomEvent: InputCustomEvent,
|
|
3862
3958
|
InputEvalEvent: InputEvalEvent,
|
|
3863
3959
|
InputIdentifyEvent: InputIdentifyEvent,
|
|
3960
|
+
MAX_STREAMING_REDIRECT_HOPS: MAX_STREAMING_REDIRECT_HOPS,
|
|
3864
3961
|
NullEventProcessor: NullEventProcessor,
|
|
3865
3962
|
PayloadProcessor: PayloadProcessor,
|
|
3866
3963
|
PayloadStreamReader: PayloadStreamReader,
|
|
3867
3964
|
canonicalize: canonicalize,
|
|
3868
3965
|
createProtocolHandler: createProtocolHandler,
|
|
3869
3966
|
createStreamingResponse: createStreamingResponse,
|
|
3967
|
+
followStreamingRedirects: followStreamingRedirects,
|
|
3870
3968
|
initMetadataFromHeaders: initMetadataFromHeaders,
|
|
3871
3969
|
isLegacyUser: isLegacyUser,
|
|
3872
3970
|
isMultiKind: isMultiKind,
|