@launchdarkly/js-sdk-common 2.16.0 → 2.17.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 +7 -0
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.d.ts.map +1 -1
- package/dist/cjs/api/integrations/index.d.ts +2 -0
- package/dist/cjs/api/integrations/index.d.ts.map +1 -0
- package/dist/cjs/api/integrations/plugins.d.ts +128 -0
- package/dist/cjs/api/integrations/plugins.d.ts.map +1 -0
- package/dist/cjs/api/subsystem/DataSystem/CallbackHandler.d.ts +16 -0
- package/dist/cjs/api/subsystem/DataSystem/CallbackHandler.d.ts.map +1 -0
- package/dist/cjs/api/subsystem/DataSystem/DataSource.d.ts +21 -0
- package/dist/cjs/api/subsystem/DataSystem/DataSource.d.ts.map +1 -0
- package/dist/cjs/api/subsystem/DataSystem/index.d.ts +2 -0
- package/dist/cjs/api/subsystem/DataSystem/index.d.ts.map +1 -0
- package/dist/cjs/api/subsystem/index.d.ts +2 -1
- package/dist/cjs/api/subsystem/index.d.ts.map +1 -1
- package/dist/cjs/datasource/Backoff.d.ts +46 -0
- package/dist/cjs/datasource/Backoff.d.ts.map +1 -0
- package/dist/cjs/datasource/CompositeDataSource.d.ts +62 -0
- package/dist/cjs/datasource/CompositeDataSource.d.ts.map +1 -0
- package/dist/cjs/datasource/dataSourceList.d.ts +47 -0
- package/dist/cjs/datasource/dataSourceList.d.ts.map +1 -0
- package/dist/cjs/datasource/index.d.ts +3 -1
- package/dist/cjs/datasource/index.d.ts.map +1 -1
- package/dist/cjs/index.cjs +648 -38
- 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 -2
- package/dist/cjs/internal/fdv2/index.d.ts.map +1 -1
- package/dist/cjs/internal/fdv2/{payloadReader.d.ts → payloadProcessor.d.ts} +27 -16
- package/dist/cjs/internal/fdv2/payloadProcessor.d.ts.map +1 -0
- package/dist/cjs/internal/fdv2/payloadStreamReader.d.ts +31 -0
- package/dist/cjs/internal/fdv2/payloadStreamReader.d.ts.map +1 -0
- package/dist/cjs/internal/index.d.ts +1 -0
- package/dist/cjs/internal/index.d.ts.map +1 -1
- package/dist/cjs/internal/plugins/index.d.ts +4 -0
- package/dist/cjs/internal/plugins/index.d.ts.map +1 -0
- package/dist/cjs/internal/plugins/safeGetHooks.d.ts +4 -0
- package/dist/cjs/internal/plugins/safeGetHooks.d.ts.map +1 -0
- package/dist/cjs/internal/plugins/safeGetName.d.ts +4 -0
- package/dist/cjs/internal/plugins/safeGetName.d.ts.map +1 -0
- package/dist/cjs/internal/plugins/safeRegisterPlugins.d.ts +4 -0
- package/dist/cjs/internal/plugins/safeRegisterPlugins.d.ts.map +1 -0
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/api/index.d.ts.map +1 -1
- package/dist/esm/api/integrations/index.d.ts +2 -0
- package/dist/esm/api/integrations/index.d.ts.map +1 -0
- package/dist/esm/api/integrations/plugins.d.ts +128 -0
- package/dist/esm/api/integrations/plugins.d.ts.map +1 -0
- package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts +16 -0
- package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts.map +1 -0
- package/dist/esm/api/subsystem/DataSystem/DataSource.d.ts +21 -0
- package/dist/esm/api/subsystem/DataSystem/DataSource.d.ts.map +1 -0
- package/dist/esm/api/subsystem/DataSystem/index.d.ts +2 -0
- package/dist/esm/api/subsystem/DataSystem/index.d.ts.map +1 -0
- package/dist/esm/api/subsystem/index.d.ts +2 -1
- package/dist/esm/api/subsystem/index.d.ts.map +1 -1
- package/dist/esm/datasource/Backoff.d.ts +46 -0
- package/dist/esm/datasource/Backoff.d.ts.map +1 -0
- package/dist/esm/datasource/CompositeDataSource.d.ts +62 -0
- package/dist/esm/datasource/CompositeDataSource.d.ts.map +1 -0
- package/dist/esm/datasource/dataSourceList.d.ts +47 -0
- package/dist/esm/datasource/dataSourceList.d.ts.map +1 -0
- package/dist/esm/datasource/index.d.ts +3 -1
- 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 +647 -39
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/fdv2/index.d.ts +3 -2
- package/dist/esm/internal/fdv2/index.d.ts.map +1 -1
- package/dist/esm/internal/fdv2/{payloadReader.d.ts → payloadProcessor.d.ts} +27 -16
- package/dist/esm/internal/fdv2/payloadProcessor.d.ts.map +1 -0
- package/dist/esm/internal/fdv2/payloadStreamReader.d.ts +31 -0
- package/dist/esm/internal/fdv2/payloadStreamReader.d.ts.map +1 -0
- package/dist/esm/internal/index.d.ts +1 -0
- package/dist/esm/internal/index.d.ts.map +1 -1
- package/dist/esm/internal/plugins/index.d.ts +4 -0
- package/dist/esm/internal/plugins/index.d.ts.map +1 -0
- package/dist/esm/internal/plugins/safeGetHooks.d.ts +4 -0
- package/dist/esm/internal/plugins/safeGetHooks.d.ts.map +1 -0
- package/dist/esm/internal/plugins/safeGetName.d.ts +4 -0
- package/dist/esm/internal/plugins/safeGetName.d.ts.map +1 -0
- package/dist/esm/internal/plugins/safeRegisterPlugins.d.ts +4 -0
- package/dist/esm/internal/plugins/safeRegisterPlugins.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/internal/fdv2/payloadReader.d.ts.map +0 -1
- package/dist/esm/internal/fdv2/payloadReader.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.17.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.16.0...js-sdk-common-v2.17.0) (2025-04-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Add client-side SDK plugin support. ([#834](https://github.com/launchdarkly/js-core/issues/834)) ([a843a33](https://github.com/launchdarkly/js-core/commit/a843a33e97dcab706a0034bd1fd1e3d2f78a9262))
|
|
11
|
+
|
|
5
12
|
## [2.16.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.15.0...js-sdk-common-v2.16.0) (2025-04-16)
|
|
6
13
|
|
|
7
14
|
|
package/dist/cjs/api/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/integrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta-data about a plugin implementation.
|
|
3
|
+
*
|
|
4
|
+
* May be used in logs and analytics to identify the plugin.
|
|
5
|
+
*/
|
|
6
|
+
export interface LDPluginMetadata {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the plugin.
|
|
9
|
+
*/
|
|
10
|
+
readonly name: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Metadata about the SDK that is running the plugin.
|
|
14
|
+
*/
|
|
15
|
+
export interface LDPluginSdkMetadata {
|
|
16
|
+
/**
|
|
17
|
+
* The name of the SDK.
|
|
18
|
+
*/
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/**
|
|
21
|
+
* The version of the SDK.
|
|
22
|
+
*/
|
|
23
|
+
readonly version: string;
|
|
24
|
+
/**
|
|
25
|
+
* If this is a wrapper SDK, then this is the name of the wrapper.
|
|
26
|
+
*/
|
|
27
|
+
readonly wrapperName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* If this is a wrapper SDK, then this is the version of the wrapper.
|
|
30
|
+
*/
|
|
31
|
+
readonly wrapperVersion?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Metadata about the application where the LaunchDarkly SDK is running.
|
|
35
|
+
*/
|
|
36
|
+
export interface LDPluginApplicationMetadata {
|
|
37
|
+
/**
|
|
38
|
+
* A unique identifier representing the application where the LaunchDarkly SDK is running.
|
|
39
|
+
*
|
|
40
|
+
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
|
|
41
|
+
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
|
|
42
|
+
*
|
|
43
|
+
* Example: `authentication-service`
|
|
44
|
+
*/
|
|
45
|
+
readonly id?: string;
|
|
46
|
+
/**
|
|
47
|
+
* A unique identifier representing the version of the application where the LaunchDarkly SDK is running.
|
|
48
|
+
*
|
|
49
|
+
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
|
|
50
|
+
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
|
|
51
|
+
*
|
|
52
|
+
* Example: `1.0.0` (standard version string) or `abcdef` (sha prefix)
|
|
53
|
+
*/
|
|
54
|
+
readonly version?: string;
|
|
55
|
+
/**
|
|
56
|
+
* A human-friendly application name representing the application where the LaunchDarkly SDK is running.
|
|
57
|
+
*
|
|
58
|
+
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
|
|
59
|
+
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
|
|
60
|
+
*/
|
|
61
|
+
readonly name?: string;
|
|
62
|
+
/**
|
|
63
|
+
* A human-friendly name representing the version of the application where the LaunchDarkly SDK is running.
|
|
64
|
+
*
|
|
65
|
+
* This can be specified as any string value as long as it only uses the following characters: ASCII letters,
|
|
66
|
+
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
|
|
67
|
+
*/
|
|
68
|
+
readonly versionName?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Metadata about the environment where the plugin is running.
|
|
72
|
+
*/
|
|
73
|
+
export interface LDPluginEnvironmentMetadata {
|
|
74
|
+
/**
|
|
75
|
+
* Metadata about the SDK that is running the plugin.
|
|
76
|
+
*/
|
|
77
|
+
readonly sdk: LDPluginSdkMetadata;
|
|
78
|
+
/**
|
|
79
|
+
* Metadata about the application where the LaunchDarkly SDK is running.
|
|
80
|
+
*
|
|
81
|
+
* Only present if any application information is available.
|
|
82
|
+
*/
|
|
83
|
+
readonly application?: LDPluginApplicationMetadata;
|
|
84
|
+
/**
|
|
85
|
+
* Present if the SDK is a client-side SDK running in a web environment.
|
|
86
|
+
*/
|
|
87
|
+
readonly clientSideId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Present if the SDK is a client-side SDK running in a mobile environment.
|
|
90
|
+
*/
|
|
91
|
+
readonly mobileKey?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Present if the SDK is a server-side SDK.
|
|
94
|
+
*/
|
|
95
|
+
readonly sdkKey?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Interface for plugins to the LaunchDarkly SDK.
|
|
99
|
+
*
|
|
100
|
+
* This is the base interface common to client-side and server-side SDKs. This interface should be re-exported by SDKs
|
|
101
|
+
* using the specific SDK's client type for the `TClient` parameter, and the specific SDK's hook type for the `THook` parameter.
|
|
102
|
+
*/
|
|
103
|
+
export interface LDPluginBase<TClient, THook> {
|
|
104
|
+
/**
|
|
105
|
+
* Get metadata about the plugin.
|
|
106
|
+
*/
|
|
107
|
+
getMetadata(): LDPluginMetadata;
|
|
108
|
+
/**
|
|
109
|
+
* Registers the plugin with the SDK. Called once during SDK initialization.
|
|
110
|
+
*
|
|
111
|
+
* The SDK initialization will typically not have been completed at this point, so the plugin should take appropriate
|
|
112
|
+
* actions to ensure the SDK is ready before sending track events or evaluating flags.
|
|
113
|
+
*
|
|
114
|
+
* @param client The SDK client instance.
|
|
115
|
+
* @param environmentMetadata Information about the environment where the plugin is running.
|
|
116
|
+
*/
|
|
117
|
+
register(client: TClient, environmentMetadata: LDPluginEnvironmentMetadata): void;
|
|
118
|
+
/**
|
|
119
|
+
* Gets a list of hooks that the plugin wants to register.
|
|
120
|
+
*
|
|
121
|
+
* This method will be called once during SDK initialization before the register method is called.
|
|
122
|
+
*
|
|
123
|
+
* If the plugin does not need to register any hooks, this method doesn't need to be implemented.
|
|
124
|
+
* @param metadata
|
|
125
|
+
*/
|
|
126
|
+
getHooks?(metadata: LDPluginEnvironmentMetadata): THook[];
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../src/api/integrations/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,OAAO,EAAE,KAAK;IAC1C;;OAEG;IACH,WAAW,IAAI,gBAAgB,CAAC;IAEhC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAElF;;;;;;;OAOG;IACH,QAAQ,CAAC,CAAC,QAAQ,EAAE,2BAA2B,GAAG,KAAK,EAAE,CAAC;CAC3D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataSourceState } from './DataSource';
|
|
2
|
+
/**
|
|
3
|
+
* Handler that connects the current {@link DataSource} to the {@link CompositeDataSource}. A single
|
|
4
|
+
* {@link CallbackHandler} should only be given to one {@link DataSource}. Use {@link disable()} to
|
|
5
|
+
* prevent additional callback events.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CallbackHandler {
|
|
8
|
+
private readonly _dataCallback;
|
|
9
|
+
private readonly _statusCallback;
|
|
10
|
+
private _disabled;
|
|
11
|
+
constructor(_dataCallback: (basis: boolean, data: any) => void, _statusCallback: (status: DataSourceState, err?: any) => void);
|
|
12
|
+
disable(): void;
|
|
13
|
+
dataHandler(basis: boolean, data: any): Promise<void>;
|
|
14
|
+
statusHandler(status: DataSourceState, err?: any): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=CallbackHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallbackHandler.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/CallbackHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJlC,OAAO,CAAC,SAAS,CAAkB;gBAGhB,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EAClD,eAAe,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI;IAGhF,OAAO;IAID,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG;IAUrC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG;CAOvD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum DataSourceState {
|
|
2
|
+
Valid = 0,
|
|
3
|
+
Initializing = 1,
|
|
4
|
+
Interrupted = 2,
|
|
5
|
+
Closed = 3
|
|
6
|
+
}
|
|
7
|
+
export interface DataSource {
|
|
8
|
+
/**
|
|
9
|
+
* May be called any number of times, if already started, has no effect
|
|
10
|
+
* @param dataCallback that will be called when data arrives, may be called multiple times.
|
|
11
|
+
* @param statusCallback that will be called when data source state changes or an unrecoverable error
|
|
12
|
+
* has been encountered.
|
|
13
|
+
*/
|
|
14
|
+
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* May be called any number of times, if already stopped, has no effect.
|
|
17
|
+
*/
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
20
|
+
export type LDDataSourceFactory = () => DataSource;
|
|
21
|
+
//# sourceMappingURL=DataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSource.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/DataSource.ts"],"names":[],"mappings":"AACA,oBAAY,eAAe;IAEzB,KAAK,IAAA;IAEL,YAAY,IAAA;IAEZ,WAAW,IAAA;IAEX,MAAM,IAAA;CACP;AAED,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,KAAK,CACH,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,GAC3D,IAAI,CAAC;IAER;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { DataSource, DataSourceState, LDDataSourceFactory } from './DataSystem';
|
|
1
2
|
import LDContextDeduplicator from './LDContextDeduplicator';
|
|
2
3
|
import LDEventProcessor from './LDEventProcessor';
|
|
3
4
|
import LDEventSender, { LDDeliveryStatus, LDEventSenderResult, LDEventType } from './LDEventSender';
|
|
4
5
|
import { LDStreamProcessor } from './LDStreamProcessor';
|
|
5
|
-
export { LDEventProcessor, LDContextDeduplicator, LDEventSender, LDDeliveryStatus, LDEventType, LDEventSenderResult, LDStreamProcessor, };
|
|
6
|
+
export { DataSource, DataSourceState, LDDataSourceFactory, LDEventProcessor, LDContextDeduplicator, LDEventSender, LDDeliveryStatus, LDEventType, LDEventSenderResult, LDStreamProcessor, };
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/subsystem/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,aAAa,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,GAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/subsystem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,aAAa,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface Backoff {
|
|
2
|
+
success(): void;
|
|
3
|
+
fail(): number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Implements exponential backoff and jitter. This class tracks successful connections and failures
|
|
7
|
+
* and produces a retry delay.
|
|
8
|
+
*
|
|
9
|
+
* It does not start any timers or directly control a connection.
|
|
10
|
+
*
|
|
11
|
+
* The backoff follows an exponential backoff scheme with 50% jitter starting at
|
|
12
|
+
* initialRetryDelayMillis and capping at MAX_RETRY_DELAY. If RESET_INTERVAL has elapsed after a
|
|
13
|
+
* success, without an intervening faulure, then the backoff is reset to initialRetryDelayMillis.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DefaultBackoff {
|
|
16
|
+
private readonly _retryResetIntervalMillis;
|
|
17
|
+
private readonly _random;
|
|
18
|
+
private _retryCount;
|
|
19
|
+
private _activeSince?;
|
|
20
|
+
private _initialRetryDelayMillis;
|
|
21
|
+
/**
|
|
22
|
+
* The exponent at which the backoff delay will exceed the maximum.
|
|
23
|
+
* Beyond this limit the backoff can be set to the max.
|
|
24
|
+
*/
|
|
25
|
+
private readonly _maxExponent;
|
|
26
|
+
constructor(initialRetryDelayMillis: number, _retryResetIntervalMillis: number, _random?: () => number);
|
|
27
|
+
private _backoff;
|
|
28
|
+
private _jitter;
|
|
29
|
+
/**
|
|
30
|
+
* This function should be called when a connection attempt is successful.
|
|
31
|
+
*
|
|
32
|
+
* @param timeStampMs The time of the success. Used primarily for testing, when not provided
|
|
33
|
+
* the current time is used.
|
|
34
|
+
*/
|
|
35
|
+
success(timeStampMs?: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* This function should be called when a connection fails. It returns the a delay, in
|
|
38
|
+
* milliseconds, after which a reconnection attempt should be made.
|
|
39
|
+
*
|
|
40
|
+
* @param timeStampMs The time of the success. Used primarily for testing, when not provided
|
|
41
|
+
* the current time is used.
|
|
42
|
+
* @returns The delay before the next connection attempt.
|
|
43
|
+
*/
|
|
44
|
+
fail(timeStampMs?: number): number;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=Backoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Backoff.d.ts","sourceRoot":"","sources":["../../src/datasource/Backoff.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,OAAO;IACtB,OAAO,IAAI,IAAI,CAAC;IAChB,IAAI,IAAI,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAc;IAYvB,OAAO,CAAC,QAAQ,CAAC,yBAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZ1B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,wBAAwB,CAAS;IACzC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGpC,uBAAuB,EAAE,MAAM,EACd,yBAAyB,EAAE,MAAM,EACjC,OAAO,eAAc;IAOxC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,OAAO;IAIf;;;;;OAKG;IACH,OAAO,CAAC,WAAW,GAAE,MAAmB,GAAG,IAAI;IAI/C;;;;;;;OAOG;IACH,IAAI,CAAC,WAAW,GAAE,MAAmB,GAAG,MAAM;CAc/C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { LDLogger } from '../api/logging';
|
|
2
|
+
import { DataSource, DataSourceState, LDDataSourceFactory } from '../api/subsystem/DataSystem/DataSource';
|
|
3
|
+
import { Backoff } from './Backoff';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a transition between data sources.
|
|
6
|
+
*/
|
|
7
|
+
export type Transition = 'switchToSync' | 'fallback' | 'recover' | 'stop';
|
|
8
|
+
/**
|
|
9
|
+
* Given a {@link DataSourceState}, how long to wait before transitioning.
|
|
10
|
+
*/
|
|
11
|
+
export type TransitionConditions = {
|
|
12
|
+
[k in DataSourceState]?: {
|
|
13
|
+
durationMS: number;
|
|
14
|
+
transition: Transition;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The {@link CompositeDataSource} can combine a number of {@link DataSystemInitializer}s and {@link DataSystemSynchronizer}s
|
|
19
|
+
* into a single {@link DataSource}, implementing fallback and recovery logic internally to choose where data is sourced from.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CompositeDataSource implements DataSource {
|
|
22
|
+
private readonly _logger?;
|
|
23
|
+
private readonly _transitionConditions;
|
|
24
|
+
private readonly _backoff;
|
|
25
|
+
private _initPhaseActive;
|
|
26
|
+
private _initFactories;
|
|
27
|
+
private _syncFactories;
|
|
28
|
+
private _stopped;
|
|
29
|
+
private _externalTransitionPromise;
|
|
30
|
+
private _externalTransitionResolve?;
|
|
31
|
+
private _cancelTokens;
|
|
32
|
+
/**
|
|
33
|
+
* @param initializers factories to create {@link DataSystemInitializer}s, in priority order.
|
|
34
|
+
* @param synchronizers factories to create {@link DataSystemSynchronizer}s, in priority order.
|
|
35
|
+
*/
|
|
36
|
+
constructor(initializers: LDDataSourceFactory[], synchronizers: LDDataSourceFactory[], _logger?: LDLogger | undefined, _transitionConditions?: TransitionConditions, _backoff?: Backoff);
|
|
37
|
+
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void): Promise<void>;
|
|
38
|
+
stop(): Promise<void>;
|
|
39
|
+
private _reset;
|
|
40
|
+
/**
|
|
41
|
+
* Determines the next datasource and returns that datasource as well as a closure to cull the
|
|
42
|
+
* datasource from the datasource lists. One example where the cull closure is invoked is if the
|
|
43
|
+
* datasource has an unrecoverable error.
|
|
44
|
+
*/
|
|
45
|
+
private _pickDataSource;
|
|
46
|
+
/**
|
|
47
|
+
* @returns the transition condition for the provided data source state or undefined
|
|
48
|
+
* if there is no transition condition
|
|
49
|
+
*/
|
|
50
|
+
private _lookupTransitionCondition;
|
|
51
|
+
private _cancellableDelay;
|
|
52
|
+
private _consumeCancelToken;
|
|
53
|
+
/**
|
|
54
|
+
* This wrapper will ensure the following:
|
|
55
|
+
*
|
|
56
|
+
* Don't report DataSourceState.Initializing except as first status callback.
|
|
57
|
+
* Map underlying DataSourceState.Closed to interrupted.
|
|
58
|
+
* Don't report the same status and error twice in a row.
|
|
59
|
+
*/
|
|
60
|
+
private _wrapStatusCallbackWithSanitizer;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=CompositeDataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeDataSource.d.ts","sourceRoot":"","sources":["../../src/datasource/CompositeDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAMpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE;CACxE,CAAC;AAOF;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,UAAU;IAoBlD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAUtC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IA3B3B,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,cAAc,CAAsC;IAE5D,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,0BAA0B,CAA6B;IAC/D,OAAO,CAAC,0BAA0B,CAAC,CAAqC;IACxE,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;OAGG;gBAED,YAAY,EAAE,mBAAmB,EAAE,EACnC,aAAa,EAAE,mBAAmB,EAAE,EACnB,OAAO,CAAC,sBAAU,EAClB,qBAAqB,GAAE,oBASvC,EACgB,QAAQ,GAAE,OAAyC;IAUhE,KAAK,CACT,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,GAC3D,OAAO,CAAC,IAAI,CAAC;IAgJV,IAAI;IAMV,OAAO,CAAC,MAAM;IAWd;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAoDvB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,iBAAiB,CAcvB;IAEF,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;CAgCzC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper class for {@link CompositeDataSource} to manage iterating on data sources and removing them on the fly.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DataSourceList<T> {
|
|
5
|
+
private _list;
|
|
6
|
+
private _circular;
|
|
7
|
+
private _pos;
|
|
8
|
+
/**
|
|
9
|
+
* @param circular whether to loop off the end of the list back to the start
|
|
10
|
+
* @param initialList of content
|
|
11
|
+
*/
|
|
12
|
+
constructor(circular: boolean, initialList?: T[]);
|
|
13
|
+
/**
|
|
14
|
+
* Returns the current head and then iterates.
|
|
15
|
+
*/
|
|
16
|
+
next(): T | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Replaces all elements with the provided list and resets the position of head to the start.
|
|
19
|
+
*
|
|
20
|
+
* @param input that will replace existing list
|
|
21
|
+
*/
|
|
22
|
+
replace(input: T[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Removes the provided element from the list. If the removed element was the head, head moves to next. Consider head may be undefined if list is empty after removal.
|
|
25
|
+
*
|
|
26
|
+
* @param element to remove
|
|
27
|
+
* @returns true if element was removed
|
|
28
|
+
*/
|
|
29
|
+
remove(element: T): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Reset the head position to the start of the list.
|
|
32
|
+
*/
|
|
33
|
+
reset(): void;
|
|
34
|
+
/**
|
|
35
|
+
* @returns the current head position in the list, 0 indexed.
|
|
36
|
+
*/
|
|
37
|
+
pos(): number;
|
|
38
|
+
/**
|
|
39
|
+
* @returns the current length of the list
|
|
40
|
+
*/
|
|
41
|
+
length(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Clears the list and resets head.
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=dataSourceList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataSourceList.d.ts","sourceRoot":"","sources":["../../src/datasource/dataSourceList.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,IAAI,CAAS;IAErB;;;OAGG;gBACS,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE;IAMhD;;OAEG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS;IAgBrB;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI;IAKzB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO;IAoB3B;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,GAAG;IAIH;;OAEG;IACH,MAAM;IAIN;;OAEG;IACH,KAAK;CAIN"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Backoff, DefaultBackoff } from './Backoff';
|
|
2
|
+
import { CompositeDataSource } from './CompositeDataSource';
|
|
1
3
|
import { DataSourceErrorKind } from './DataSourceErrorKinds';
|
|
2
4
|
import { LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors';
|
|
3
|
-
export { DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler, };
|
|
5
|
+
export { Backoff, CompositeDataSource, DefaultBackoff, DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler, };
|
|
4
6
|
//# 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,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|