@launchdarkly/js-sdk-common 2.11.0 → 2.13.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 +19 -0
- package/dist/cjs/api/context/LDContext.d.ts +16 -1
- package/dist/cjs/api/context/LDContext.d.ts.map +1 -1
- package/dist/cjs/api/context/LDContextCommon.d.ts +3 -0
- package/dist/cjs/api/context/LDContextCommon.d.ts.map +1 -1
- package/dist/cjs/api/context/LDUser.d.ts +0 -4
- package/dist/cjs/api/context/LDUser.d.ts.map +1 -1
- package/dist/cjs/api/logging/BasicLoggerOptions.d.ts +7 -4
- package/dist/cjs/api/logging/BasicLoggerOptions.d.ts.map +1 -1
- package/dist/cjs/api/platform/AutoEnv.d.ts +0 -2
- package/dist/cjs/api/platform/AutoEnv.d.ts.map +1 -1
- package/dist/cjs/api/platform/EventSource.d.ts +1 -1
- package/dist/cjs/api/platform/EventSource.d.ts.map +1 -1
- package/dist/cjs/datasource/errors.d.ts +1 -0
- package/dist/cjs/datasource/errors.d.ts.map +1 -1
- package/dist/cjs/datasource/index.d.ts +2 -2
- package/dist/cjs/datasource/index.d.ts.map +1 -1
- package/dist/cjs/index.cjs +170 -104
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internal/fdv2/index.d.ts +3 -0
- package/dist/cjs/internal/fdv2/index.d.ts.map +1 -0
- package/dist/cjs/internal/fdv2/payloadReader.d.ts +58 -0
- package/dist/cjs/internal/fdv2/payloadReader.d.ts.map +1 -0
- package/dist/cjs/internal/fdv2/proto.d.ts +30 -0
- package/dist/cjs/internal/fdv2/proto.d.ts.map +1 -0
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.d.ts.map +1 -1
- package/dist/cjs/logging/BasicLogger.d.ts +1 -1
- package/dist/cjs/logging/BasicLogger.d.ts.map +1 -1
- package/dist/esm/api/context/LDContext.d.ts +16 -1
- package/dist/esm/api/context/LDContext.d.ts.map +1 -1
- package/dist/esm/api/context/LDContextCommon.d.ts +3 -0
- package/dist/esm/api/context/LDContextCommon.d.ts.map +1 -1
- package/dist/esm/api/context/LDUser.d.ts +0 -4
- package/dist/esm/api/context/LDUser.d.ts.map +1 -1
- package/dist/esm/api/logging/BasicLoggerOptions.d.ts +7 -4
- package/dist/esm/api/logging/BasicLoggerOptions.d.ts.map +1 -1
- package/dist/esm/api/platform/AutoEnv.d.ts +0 -2
- package/dist/esm/api/platform/AutoEnv.d.ts.map +1 -1
- package/dist/esm/api/platform/EventSource.d.ts +1 -1
- package/dist/esm/api/platform/EventSource.d.ts.map +1 -1
- package/dist/esm/datasource/errors.d.ts +1 -0
- package/dist/esm/datasource/errors.d.ts.map +1 -1
- package/dist/esm/datasource/index.d.ts +2 -2
- package/dist/esm/datasource/index.d.ts.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +170 -104
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/fdv2/index.d.ts +3 -0
- package/dist/esm/internal/fdv2/index.d.ts.map +1 -0
- package/dist/esm/internal/fdv2/payloadReader.d.ts +58 -0
- package/dist/esm/internal/fdv2/payloadReader.d.ts.map +1 -0
- package/dist/esm/internal/fdv2/proto.d.ts +30 -0
- package/dist/esm/internal/fdv2/proto.d.ts.map +1 -0
- package/dist/esm/internal/index.d.ts +1 -1
- package/dist/esm/internal/index.d.ts.map +1 -1
- package/dist/esm/logging/BasicLogger.d.ts +1 -1
- package/dist/esm/logging/BasicLogger.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/internal/stream/StreamingProcessor.d.ts +0 -39
- package/dist/cjs/internal/stream/StreamingProcessor.d.ts.map +0 -1
- package/dist/cjs/internal/stream/index.d.ts +0 -5
- package/dist/cjs/internal/stream/index.d.ts.map +0 -1
- package/dist/cjs/internal/stream/types.d.ts +0 -3
- package/dist/cjs/internal/stream/types.d.ts.map +0 -1
- package/dist/esm/internal/stream/StreamingProcessor.d.ts +0 -39
- package/dist/esm/internal/stream/StreamingProcessor.d.ts.map +0 -1
- package/dist/esm/internal/stream/index.d.ts +0 -5
- package/dist/esm/internal/stream/index.d.ts.map +0 -1
- package/dist/esm/internal/stream/types.d.ts +0 -3
- package/dist/esm/internal/stream/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.13.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.12.0...js-sdk-common-v2.13.0) (2025-01-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Adds StreamingProcessor for FDv2 to sdk-server package. ([#707](https://github.com/launchdarkly/js-core/issues/707)) ([7f5c275](https://github.com/launchdarkly/js-core/commit/7f5c2750dcc8341d049d7e736ca21ec36e168703))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Remove outdated reference to geolocation. ([#719](https://github.com/launchdarkly/js-core/issues/719)) ([0eeb3b6](https://github.com/launchdarkly/js-core/commit/0eeb3b6472419d257bf52c4ab3ae33864eae1902))
|
|
16
|
+
|
|
17
|
+
## [2.12.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.11.0...js-sdk-common-v2.12.0) (2024-11-04)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Enhance basic logger destination support. ([#650](https://github.com/launchdarkly/js-core/issues/650)) ([21670c4](https://github.com/launchdarkly/js-core/commit/21670c4acd629f7ccfeb7abbe94fe89723533600))
|
|
23
|
+
|
|
5
24
|
## [2.11.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.10.0...js-sdk-common-v2.11.0) (2024-10-17)
|
|
6
25
|
|
|
7
26
|
|
|
@@ -2,7 +2,22 @@ import { LDMultiKindContext } from './LDMultiKindContext';
|
|
|
2
2
|
import { LDSingleKindContext } from './LDSingleKindContext';
|
|
3
3
|
import { LDUser } from './LDUser';
|
|
4
4
|
/**
|
|
5
|
-
* A LaunchDarkly context object.
|
|
5
|
+
* A LaunchDarkly context object. LaunchDarkly contexts are objects representing users, devices, organizations, and
|
|
6
|
+
* other entities that feature flags serve different variations to according to your flag targeting rules. These data
|
|
7
|
+
* objects contain context attributes that describe what you know about that context, such as their name, location,
|
|
8
|
+
* device type, or organization they are associated with.
|
|
9
|
+
*
|
|
10
|
+
* You can manage how contexts interact with your app by targeting flag variations to specific contexts, based on
|
|
11
|
+
* their context attributes. When a flag evaluation occurs, the feature flag uses the evaluation context to understand
|
|
12
|
+
* what variation to serve. You can be as specific as targeting a flag to a single end context, or as broad as targeting
|
|
13
|
+
* your entire customer base. You can even use anonymous contexts and private attributes to control what data to
|
|
14
|
+
* include or exclude in the information you collect about your end users.
|
|
15
|
+
*
|
|
16
|
+
* LDContext is the newer replacement for the previous, less flexible LDUser type. The current SDK still supports
|
|
17
|
+
* LDUser, but LDContext is now the preferred model.
|
|
18
|
+
*
|
|
19
|
+
* See {@link LDSingleKindContext} and {@link LDMultiKindContext} for examples. {@link LDContextCommon} includes
|
|
20
|
+
* additional propert
|
|
6
21
|
*/
|
|
7
22
|
export type LDContext = LDUser | LDSingleKindContext | LDMultiKindContext;
|
|
8
23
|
//# sourceMappingURL=LDContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LDContext.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"LDContext.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,mBAAmB,GAAG,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LDContextCommon.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDContextCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B"}
|
|
1
|
+
{"version":3,"file":"LDContextCommon.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDContextCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B"}
|
|
@@ -35,10 +35,6 @@ export interface LDUser {
|
|
|
35
35
|
avatar?: string;
|
|
36
36
|
/**
|
|
37
37
|
* The user's IP address.
|
|
38
|
-
*
|
|
39
|
-
* If you provide an IP, LaunchDarkly will use a geolocation service to
|
|
40
|
-
* automatically infer a `country` for the user, unless you've already
|
|
41
|
-
* specified one.
|
|
42
38
|
*/
|
|
43
39
|
ip?: string;
|
|
44
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LDUser.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDUser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB
|
|
1
|
+
{"version":3,"file":"LDUser.d.ts","sourceRoot":"","sources":["../../../src/api/context/LDUser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;KAC7E,CAAC;IAEF;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACvC"}
|
|
@@ -18,18 +18,21 @@ export interface BasicLoggerOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
name?: string;
|
|
20
20
|
/**
|
|
21
|
-
* An optional function to use to print each log line.
|
|
21
|
+
* An optional function, or map of levels to functions, to use to print each log line.
|
|
22
22
|
*
|
|
23
|
-
* If
|
|
23
|
+
* If not specified, the default is `console.error`.
|
|
24
|
+
*
|
|
25
|
+
* If a function is specified, `basicLogger` calls it to write each line of output. The
|
|
24
26
|
* argument is a fully formatted log line, not including a linefeed. The function
|
|
25
27
|
* is only called for log levels that are enabled.
|
|
26
28
|
*
|
|
27
|
-
* If
|
|
29
|
+
* If a map is specified, then each entry will be used as the destination for the corresponding
|
|
30
|
+
* log level. Any level that is not specified will use the default of `console.error`.
|
|
28
31
|
*
|
|
29
32
|
* Setting this property to anything other than a function will cause SDK
|
|
30
33
|
* initialization to fail.
|
|
31
34
|
*/
|
|
32
|
-
destination?: (line: string) => void
|
|
35
|
+
destination?: ((line: string) => void) | Record<'debug' | 'info' | 'warn' | 'error', (line: string) => void>;
|
|
33
36
|
/**
|
|
34
37
|
* An optional formatter to use. The formatter should be compatible
|
|
35
38
|
* with node-style format strings like those used with `util.format`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicLoggerOptions.d.ts","sourceRoot":"","sources":["../../../src/api/logging/BasicLoggerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd
|
|
1
|
+
{"version":3,"file":"BasicLoggerOptions.d.ts","sourceRoot":"","sources":["../../../src/api/logging/BasicLoggerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,EACR,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GACxB,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAExE;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC;CACxC"}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* model, operating system, locale, and so on. We recommend enabling this when you configure the SDK. To learn more,
|
|
6
6
|
* read [Automatic environment attributes](https://docs.launchdarkly.com/sdk/features/environment-attributes).
|
|
7
7
|
* for more documentation.
|
|
8
|
-
*
|
|
9
|
-
* The default is disabled.
|
|
10
8
|
*/
|
|
11
9
|
export declare enum AutoEnvAttributes {
|
|
12
10
|
Disabled = 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoEnv.d.ts","sourceRoot":"","sources":["../../../src/api/platform/AutoEnv.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"AutoEnv.d.ts","sourceRoot":"","sources":["../../../src/api/platform/AutoEnv.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,oBAAY,iBAAiB;IAC3B,QAAQ,IAAA;IACR,OAAO,IAAA;CACR;AAED,UAAU,aAAa;IACrB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE;QACH;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSource.d.ts","sourceRoot":"","sources":["../../../src/api/platform/EventSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"EventSource.d.ts","sourceRoot":"","sources":["../../../src/api/platform/EventSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,GAAG,CAAA;CAAE,KAAK,IAAI,CAAC;AAC7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACzD,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAE/D,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACjE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC;IACjD,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,MAAM,CAAC;CAClC"}
|
|
@@ -14,4 +14,5 @@ export declare class LDStreamingError extends Error {
|
|
|
14
14
|
readonly recoverable: boolean;
|
|
15
15
|
constructor(kind: DataSourceErrorKind, message: string, code?: number, recoverable?: boolean);
|
|
16
16
|
}
|
|
17
|
+
export type StreamingErrorHandler = (err: LDStreamingError) => void;
|
|
17
18
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/datasource/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO5F;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO1F"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/datasource/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO5F;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO1F;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DataSourceErrorKind } from './DataSourceErrorKinds';
|
|
2
|
-
import { LDFileDataSourceError, LDPollingError, LDStreamingError } from './errors';
|
|
3
|
-
export { DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError };
|
|
2
|
+
import { LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors';
|
|
3
|
+
export { DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler, };
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -860,8 +860,6 @@ class LDStreamingError extends Error {
|
|
|
860
860
|
* model, operating system, locale, and so on. We recommend enabling this when you configure the SDK. To learn more,
|
|
861
861
|
* read [Automatic environment attributes](https://docs.launchdarkly.com/sdk/features/environment-attributes).
|
|
862
862
|
* for more documentation.
|
|
863
|
-
*
|
|
864
|
-
* The default is disabled.
|
|
865
863
|
*/
|
|
866
864
|
exports.AutoEnvAttributes = void 0;
|
|
867
865
|
(function (AutoEnvAttributes) {
|
|
@@ -1039,14 +1037,15 @@ function format(...args) {
|
|
|
1039
1037
|
return args.map(tryStringify).join(' ');
|
|
1040
1038
|
}
|
|
1041
1039
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1040
|
+
var LogPriority;
|
|
1041
|
+
(function (LogPriority) {
|
|
1042
|
+
LogPriority[LogPriority["debug"] = 0] = "debug";
|
|
1043
|
+
LogPriority[LogPriority["info"] = 1] = "info";
|
|
1044
|
+
LogPriority[LogPriority["warn"] = 2] = "warn";
|
|
1045
|
+
LogPriority[LogPriority["error"] = 3] = "error";
|
|
1046
|
+
LogPriority[LogPriority["none"] = 4] = "none";
|
|
1047
|
+
})(LogPriority || (LogPriority = {}));
|
|
1048
|
+
const LEVEL_NAMES = ['debug', 'info', 'warn', 'error', 'none'];
|
|
1050
1049
|
/**
|
|
1051
1050
|
* A basic logger which handles filtering by level.
|
|
1052
1051
|
*
|
|
@@ -1070,9 +1069,24 @@ class BasicLogger {
|
|
|
1070
1069
|
constructor(options) {
|
|
1071
1070
|
this._logLevel = LogPriority[options.level ?? 'info'] ?? LogPriority.info;
|
|
1072
1071
|
this._name = options.name ?? 'LaunchDarkly';
|
|
1073
|
-
// eslint-disable-next-line no-console
|
|
1074
|
-
this._destination = options.destination;
|
|
1075
1072
|
this._formatter = options.formatter;
|
|
1073
|
+
if (typeof options.destination === 'object') {
|
|
1074
|
+
this._destinations = {
|
|
1075
|
+
[LogPriority.debug]: options.destination.debug,
|
|
1076
|
+
[LogPriority.info]: options.destination.info,
|
|
1077
|
+
[LogPriority.warn]: options.destination.warn,
|
|
1078
|
+
[LogPriority.error]: options.destination.error,
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
else if (typeof options.destination === 'function') {
|
|
1082
|
+
const { destination } = options;
|
|
1083
|
+
this._destinations = {
|
|
1084
|
+
[LogPriority.debug]: destination,
|
|
1085
|
+
[LogPriority.info]: destination,
|
|
1086
|
+
[LogPriority.warn]: destination,
|
|
1087
|
+
[LogPriority.error]: destination,
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1076
1090
|
}
|
|
1077
1091
|
_tryFormat(...args) {
|
|
1078
1092
|
try {
|
|
@@ -1086,9 +1100,9 @@ class BasicLogger {
|
|
|
1086
1100
|
return format(...args);
|
|
1087
1101
|
}
|
|
1088
1102
|
}
|
|
1089
|
-
_tryWrite(msg) {
|
|
1103
|
+
_tryWrite(destination, msg) {
|
|
1090
1104
|
try {
|
|
1091
|
-
|
|
1105
|
+
destination(msg);
|
|
1092
1106
|
}
|
|
1093
1107
|
catch {
|
|
1094
1108
|
// eslint-disable-next-line no-console
|
|
@@ -1097,10 +1111,11 @@ class BasicLogger {
|
|
|
1097
1111
|
}
|
|
1098
1112
|
_log(level, args) {
|
|
1099
1113
|
if (level >= this._logLevel) {
|
|
1100
|
-
const prefix = `${
|
|
1114
|
+
const prefix = `${LEVEL_NAMES[level]}: [${this._name}]`;
|
|
1101
1115
|
try {
|
|
1102
|
-
|
|
1103
|
-
|
|
1116
|
+
const destination = this._destinations?.[level];
|
|
1117
|
+
if (destination) {
|
|
1118
|
+
this._tryWrite(destination, `${prefix} ${this._tryFormat(...args)}`);
|
|
1104
1119
|
}
|
|
1105
1120
|
else {
|
|
1106
1121
|
// `console.error` has its own formatter.
|
|
@@ -2311,104 +2326,155 @@ class EventFactoryBase {
|
|
|
2311
2326
|
}
|
|
2312
2327
|
}
|
|
2313
2328
|
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
class StreamingProcessor {
|
|
2321
|
-
constructor(clientContext, streamUriPath, parameters, _listeners, baseHeaders, _diagnosticsManager, _errorHandler, _streamInitialReconnectDelay = 1) {
|
|
2322
|
-
this._listeners = _listeners;
|
|
2323
|
-
this._diagnosticsManager = _diagnosticsManager;
|
|
2324
|
-
this._errorHandler = _errorHandler;
|
|
2325
|
-
this._streamInitialReconnectDelay = _streamInitialReconnectDelay;
|
|
2326
|
-
const { basicConfiguration, platform } = clientContext;
|
|
2327
|
-
const { logger } = basicConfiguration;
|
|
2328
|
-
const { requests } = platform;
|
|
2329
|
-
this._headers = { ...baseHeaders };
|
|
2330
|
-
this._logger = logger;
|
|
2331
|
-
this._requests = requests;
|
|
2332
|
-
this._streamUri = getStreamingUri(basicConfiguration.serviceEndpoints, streamUriPath, parameters);
|
|
2333
|
-
}
|
|
2334
|
-
_logConnectionStarted() {
|
|
2335
|
-
this._connectionAttemptStartTime = Date.now();
|
|
2336
|
-
}
|
|
2337
|
-
_logConnectionResult(success) {
|
|
2338
|
-
if (this._connectionAttemptStartTime && this._diagnosticsManager) {
|
|
2339
|
-
this._diagnosticsManager.recordStreamInit(this._connectionAttemptStartTime, !success, Date.now() - this._connectionAttemptStartTime);
|
|
2340
|
-
}
|
|
2341
|
-
this._connectionAttemptStartTime = undefined;
|
|
2342
|
-
}
|
|
2329
|
+
/**
|
|
2330
|
+
* A FDv2 PayloadReader can be used to parse payloads from a stream of FDv2 events. It will send payloads
|
|
2331
|
+
* to the PayloadListeners as the payloads are received. Invalid series of events may be dropped silently,
|
|
2332
|
+
* but the payload reader will continue to operate.
|
|
2333
|
+
*/
|
|
2334
|
+
class PayloadReader {
|
|
2343
2335
|
/**
|
|
2344
|
-
*
|
|
2345
|
-
* diagnostics and logging logic.
|
|
2336
|
+
* Creates a PayloadReader
|
|
2346
2337
|
*
|
|
2347
|
-
* @param
|
|
2348
|
-
* @
|
|
2349
|
-
*
|
|
2350
|
-
* @
|
|
2338
|
+
* @param eventStream event stream of FDv2 events
|
|
2339
|
+
* @param _objProcessors defines object processors for each object kind.
|
|
2340
|
+
* @param _errorHandler that will be called with errors as they are encountered
|
|
2341
|
+
* @param _logger for logging
|
|
2351
2342
|
*/
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
this.
|
|
2360
|
-
this.
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2343
|
+
constructor(eventStream, _objProcessors, _errorHandler, _logger) {
|
|
2344
|
+
this._objProcessors = _objProcessors;
|
|
2345
|
+
this._errorHandler = _errorHandler;
|
|
2346
|
+
this._logger = _logger;
|
|
2347
|
+
this._listeners = [];
|
|
2348
|
+
this._tempId = undefined;
|
|
2349
|
+
this._tempBasis = undefined;
|
|
2350
|
+
this._tempUpdates = [];
|
|
2351
|
+
this._processServerIntent = (data) => {
|
|
2352
|
+
// clear state in prep for handling data
|
|
2353
|
+
this._resetState();
|
|
2354
|
+
// if there's no payloads, return
|
|
2355
|
+
if (!data.payloads.length) {
|
|
2356
|
+
return;
|
|
2357
|
+
}
|
|
2358
|
+
// at the time of writing this, it was agreed upon that SDKs could assume exactly 1 element in this list. In the future, a negotiation of protocol version will be required to remove this assumption.
|
|
2359
|
+
const payload = data.payloads[0];
|
|
2360
|
+
switch (payload?.code) {
|
|
2361
|
+
case 'xfer-full':
|
|
2362
|
+
this._tempBasis = true;
|
|
2363
|
+
break;
|
|
2364
|
+
case 'xfer-changes':
|
|
2365
|
+
case 'none':
|
|
2366
|
+
this._tempBasis = false;
|
|
2367
|
+
break;
|
|
2368
|
+
default:
|
|
2369
|
+
// unrecognized intent code, return
|
|
2370
|
+
return;
|
|
2371
|
+
}
|
|
2372
|
+
this._tempId = payload?.id;
|
|
2377
2373
|
};
|
|
2378
|
-
|
|
2379
|
-
//
|
|
2374
|
+
this._processPutObject = (data) => {
|
|
2375
|
+
// if the following properties haven't been provided by now, we should ignore the event
|
|
2376
|
+
if (!this._tempId || // server intent hasn't been recieved yet.
|
|
2377
|
+
!data.kind ||
|
|
2378
|
+
!data.key ||
|
|
2379
|
+
!data.version ||
|
|
2380
|
+
!data.object) {
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
const obj = this._processObj(data.kind, data.object);
|
|
2384
|
+
if (!obj) {
|
|
2385
|
+
this._logger?.warn(`Unable to prcoess object for kind: '${data.kind}'`);
|
|
2386
|
+
// ignore unrecognized kinds
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2389
|
+
this._tempUpdates.push({
|
|
2390
|
+
kind: data.kind,
|
|
2391
|
+
key: data.key,
|
|
2392
|
+
version: data.version,
|
|
2393
|
+
object: obj,
|
|
2394
|
+
// intentionally omit deleted for this put
|
|
2395
|
+
});
|
|
2380
2396
|
};
|
|
2381
|
-
|
|
2382
|
-
|
|
2397
|
+
this._processDeleteObject = (data) => {
|
|
2398
|
+
// if the following properties haven't been provided by now, we should ignore the event
|
|
2399
|
+
if (!this._tempId || !data.kind || !data.key || !data.version) {
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
this._tempUpdates.push({
|
|
2403
|
+
kind: data.kind,
|
|
2404
|
+
key: data.key,
|
|
2405
|
+
version: data.version,
|
|
2406
|
+
// intentionally omit object for this delete
|
|
2407
|
+
deleted: true,
|
|
2408
|
+
});
|
|
2383
2409
|
};
|
|
2384
|
-
|
|
2385
|
-
|
|
2410
|
+
this._processPayloadTransferred = (data) => {
|
|
2411
|
+
// if the following properties haven't been provided by now, we should reset
|
|
2412
|
+
if (!this._tempId || // server intent hasn't been recieved yet.
|
|
2413
|
+
!data.state ||
|
|
2414
|
+
!data.version ||
|
|
2415
|
+
this._tempBasis === undefined) {
|
|
2416
|
+
this._resetState(); // a reset is best defensive action since payload transferred terminates a payload
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
const payload = {
|
|
2420
|
+
id: this._tempId,
|
|
2421
|
+
version: data.version,
|
|
2422
|
+
state: data.state,
|
|
2423
|
+
basis: this._tempBasis,
|
|
2424
|
+
updates: this._tempUpdates,
|
|
2425
|
+
};
|
|
2426
|
+
this._listeners.forEach((it) => it(payload));
|
|
2427
|
+
this._resetState();
|
|
2386
2428
|
};
|
|
2387
|
-
this.
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2429
|
+
this._processGoodbye = (data) => {
|
|
2430
|
+
this._logger?.info(`Goodbye was received from the LaunchDarkly connection with reason: ${data.reason}.`);
|
|
2431
|
+
this._resetState();
|
|
2432
|
+
};
|
|
2433
|
+
this._processError = (data) => {
|
|
2434
|
+
this._logger?.info(`An issue was encountered receiving updates for payload ${this._tempId} with reason: ${data.reason}. Automatic retry will occur.`);
|
|
2435
|
+
this._resetState();
|
|
2436
|
+
};
|
|
2437
|
+
this._attachHandler(eventStream, 'server-intent', this._processServerIntent);
|
|
2438
|
+
this._attachHandler(eventStream, 'put-object', this._processPutObject);
|
|
2439
|
+
this._attachHandler(eventStream, 'delete-object', this._processDeleteObject);
|
|
2440
|
+
this._attachHandler(eventStream, 'payload-transferred', this._processPayloadTransferred);
|
|
2441
|
+
this._attachHandler(eventStream, 'goodbye', this._processGoodbye);
|
|
2442
|
+
this._attachHandler(eventStream, 'error', this._processError);
|
|
2443
|
+
}
|
|
2444
|
+
addPayloadListener(listener) {
|
|
2445
|
+
this._listeners.push(listener);
|
|
2446
|
+
}
|
|
2447
|
+
removePayloadListener(listener) {
|
|
2448
|
+
const index = this._listeners.indexOf(listener, 0);
|
|
2449
|
+
if (index > -1) {
|
|
2450
|
+
this._listeners.splice(index, 1);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
_attachHandler(stream, eventName, processor) {
|
|
2454
|
+
stream.addEventListener(eventName, async (event) => {
|
|
2455
|
+
if (event?.data) {
|
|
2456
|
+
this._logger?.debug(`Received ${eventName} event. Data is ${event.data}`);
|
|
2457
|
+
try {
|
|
2458
|
+
processor(JSON.parse(event.data));
|
|
2399
2459
|
}
|
|
2400
|
-
|
|
2401
|
-
this.
|
|
2460
|
+
catch {
|
|
2461
|
+
this._logger?.error(`Stream received data that was unable to be processed in "${eventName}" message`);
|
|
2462
|
+
this._logger?.debug(`Data follows: ${event.data}`);
|
|
2463
|
+
this._errorHandler?.(exports.DataSourceErrorKind.InvalidData, 'Malformed data in event stream');
|
|
2402
2464
|
}
|
|
2403
|
-
}
|
|
2465
|
+
}
|
|
2466
|
+
else {
|
|
2467
|
+
this._errorHandler?.(exports.DataSourceErrorKind.Unknown, 'Unexpected message from event stream');
|
|
2468
|
+
}
|
|
2404
2469
|
});
|
|
2405
2470
|
}
|
|
2406
|
-
|
|
2407
|
-
this.
|
|
2408
|
-
this._eventSource = undefined;
|
|
2471
|
+
_processObj(kind, jsonObj) {
|
|
2472
|
+
return this._objProcessors[kind]?.(jsonObj);
|
|
2409
2473
|
}
|
|
2410
|
-
|
|
2411
|
-
this.
|
|
2474
|
+
_resetState() {
|
|
2475
|
+
this._tempId = undefined;
|
|
2476
|
+
this._tempBasis = undefined;
|
|
2477
|
+
this._tempUpdates = [];
|
|
2412
2478
|
}
|
|
2413
2479
|
}
|
|
2414
2480
|
|
|
@@ -2423,7 +2489,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
2423
2489
|
InputEvalEvent: InputEvalEvent,
|
|
2424
2490
|
InputIdentifyEvent: InputIdentifyEvent,
|
|
2425
2491
|
NullEventProcessor: NullEventProcessor,
|
|
2426
|
-
|
|
2492
|
+
PayloadReader: PayloadReader,
|
|
2427
2493
|
isLegacyUser: isLegacyUser,
|
|
2428
2494
|
isMultiKind: isMultiKind,
|
|
2429
2495
|
isSingleKind: isSingleKind,
|