@featbit/js-client-sdk 3.0.11 → 3.0.13
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/LICENSE +21 -21
- package/README.md +301 -301
- package/dist/esm/FbClientCore.d.ts.map +1 -1
- package/dist/esm/FbClientCore.js +1 -1
- package/dist/esm/FbClientCore.js.map +1 -1
- package/dist/esm/data-sources/DataSourceUpdates.d.ts +2 -2
- package/dist/esm/data-sources/DataSourceUpdates.d.ts.map +1 -1
- package/dist/esm/data-sources/DataSourceUpdates.js +55 -51
- package/dist/esm/data-sources/DataSourceUpdates.js.map +1 -1
- package/dist/esm/data-sources/createStreamListeners.d.ts +0 -9
- package/dist/esm/data-sources/createStreamListeners.d.ts.map +1 -1
- package/dist/esm/data-sources/createStreamListeners.js +10 -10
- package/dist/esm/data-sources/createStreamListeners.js.map +1 -1
- package/dist/esm/data-sync/IDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/IDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/NullDataSynchronizer.js +11 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/PollingDataSynchronizer.js +42 -17
- package/dist/esm/data-sync/PollingDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts +2 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js +20 -6
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js.map +1 -1
- package/dist/esm/data-sync/types.d.ts +1 -1
- package/dist/esm/data-sync/types.d.ts.map +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts.map +1 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js +3 -1
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js.map +1 -1
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts.map +1 -1
- package/dist/esm/platform/browser/BrowserWebSocket.js +4 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js.map +1 -1
- package/dist/esm/store/IDataSourceUpdates.d.ts +2 -2
- package/dist/esm/store/IDataSourceUpdates.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/{featbit-js-client-sdk-3.0.11.js → featbit-js-client-sdk-3.0.13.js} +2 -2
- package/dist/umd/featbit-js-client-sdk-3.0.13.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk.js +1 -1
- package/dist/umd/featbit-js-client-sdk.js.map +1 -1
- package/package.json +46 -46
- package/src/Configuration.ts +232 -232
- package/src/Context.ts +61 -61
- package/src/FbClientBuilder.ts +167 -167
- package/src/FbClientCore.ts +405 -401
- package/src/IContextProperty.ts +3 -3
- package/src/IDataKind.ts +11 -11
- package/src/IFbClient.ts +29 -29
- package/src/IFbClientCore.ts +290 -290
- package/src/IVersionedData.ts +18 -18
- package/src/bootstrap/IBootstrapProvider.ts +4 -4
- package/src/bootstrap/JsonBootstrapProvider.ts +34 -34
- package/src/bootstrap/NullBootstrapProvider.ts +20 -20
- package/src/bootstrap/index.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/data-sources/DataSourceUpdates.ts +116 -116
- package/src/data-sources/createStreamListeners.ts +67 -66
- package/src/data-sources/index.ts +1 -1
- package/src/data-sync/DataSyncMode.ts +3 -3
- package/src/data-sync/IDataSynchronizer.ts +15 -15
- package/src/data-sync/IRequestor.ts +10 -10
- package/src/data-sync/NullDataSynchronizer.ts +14 -14
- package/src/data-sync/PollingDataSynchronizer.ts +125 -111
- package/src/data-sync/Requestor.ts +61 -61
- package/src/data-sync/WebSocketDataSynchronizer.ts +77 -73
- package/src/data-sync/index.ts +8 -8
- package/src/data-sync/types.ts +19 -19
- package/src/data-sync/utils.ts +31 -31
- package/src/errors.ts +47 -47
- package/src/evaluation/EvalResult.ts +35 -35
- package/src/evaluation/Evaluator.ts +26 -26
- package/src/evaluation/IEvalDetail.ts +23 -23
- package/src/evaluation/ReasonKinds.ts +9 -9
- package/src/evaluation/data/IFlag.ts +29 -29
- package/src/evaluation/index.ts +4 -4
- package/src/events/DefaultEventProcessor.ts +83 -83
- package/src/events/DefaultEventQueue.ts +49 -49
- package/src/events/DefaultEventSender.ts +73 -73
- package/src/events/DefaultEventSerializer.ts +11 -11
- package/src/events/EventDispatcher.ts +127 -127
- package/src/events/EventSerializer.ts +4 -4
- package/src/events/IEventProcessor.ts +8 -8
- package/src/events/IEventQueue.ts +16 -16
- package/src/events/IEventSender.ts +13 -13
- package/src/events/NullEventProcessor.ts +15 -15
- package/src/events/event.ts +129 -129
- package/src/events/index.ts +11 -11
- package/src/index.ts +21 -21
- package/src/integrations/TestLogger.ts +24 -24
- package/src/integrations/index.ts +1 -1
- package/src/integrations/test_data/FlagBuilder.ts +59 -59
- package/src/integrations/test_data/TestData.ts +57 -57
- package/src/integrations/test_data/TestDataSynchronizer.ts +49 -49
- package/src/integrations/test_data/index.ts +4 -4
- package/src/logging/BasicLogger.ts +108 -108
- package/src/logging/IBasicLoggerOptions.ts +46 -46
- package/src/logging/ILogger.ts +49 -49
- package/src/logging/LogLevel.ts +8 -8
- package/src/logging/SafeLogger.ts +69 -69
- package/src/logging/format.ts +154 -154
- package/src/logging/index.ts +5 -5
- package/src/options/ClientContext.ts +39 -39
- package/src/options/IClientContext.ts +53 -53
- package/src/options/IOptions.ts +123 -123
- package/src/options/IUser.ts +6 -6
- package/src/options/IValidatedOptions.ts +29 -29
- package/src/options/OptionMessages.ts +35 -35
- package/src/options/UserBuilder.ts +35 -35
- package/src/options/Validators.ts +300 -300
- package/src/options/index.ts +7 -7
- package/src/platform/IInfo.ts +102 -102
- package/src/platform/IPlatform.ts +20 -20
- package/src/platform/IStore.ts +112 -112
- package/src/platform/IWebSocket.ts +22 -22
- package/src/platform/browser/BrowserInfo.ts +24 -24
- package/src/platform/browser/BrowserPlatform.ts +19 -19
- package/src/platform/browser/BrowserRequests.ts +6 -6
- package/src/platform/browser/BrowserWebSocket.ts +147 -142
- package/src/platform/browser/FbClient.ts +65 -65
- package/src/platform/browser/LocalStorageStore.ts +59 -59
- package/src/platform/index.ts +11 -11
- package/src/platform/requests.ts +76 -76
- package/src/store/BaseStore.ts +125 -125
- package/src/store/DataKinds.ts +6 -6
- package/src/store/IDataSourceUpdates.ts +68 -68
- package/src/store/InMemoryStore.ts +36 -36
- package/src/store/index.ts +5 -5
- package/src/store/serialization.ts +52 -52
- package/src/store/store.ts +37 -37
- package/src/utils/Emits.ts +75 -75
- package/src/utils/EventEmitter.ts +128 -128
- package/src/utils/IEventEmitter.ts +14 -14
- package/src/utils/Regex.ts +21 -21
- package/src/utils/ValueConverters.ts +55 -55
- package/src/utils/canonicalizeUri.ts +3 -3
- package/src/utils/debounce.ts +33 -33
- package/src/utils/http.ts +40 -40
- package/src/utils/index.ts +5 -5
- package/src/utils/isNullOrUndefined.ts +2 -2
- package/src/utils/serializeUser.ts +27 -27
- package/src/utils/sleep.ts +5 -5
- package/src/version.ts +1 -1
- package/dist/umd/featbit-js-client-sdk-3.0.11.js.map +0 -1
package/src/options/IOptions.ts
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { ILogger } from "../logging/ILogger";
|
|
2
|
-
import { IDataSynchronizer } from "../data-sync/IDataSynchronizer";
|
|
3
|
-
import { IClientContext } from "./IClientContext";
|
|
4
|
-
import { IDataSourceUpdates } from "../store/IDataSourceUpdates";
|
|
5
|
-
import { VoidFunction } from "../utils/VoidFunction";
|
|
6
|
-
import { IStore } from "../platform/IStore";
|
|
7
|
-
import { DataSyncModeEnum } from "../data-sync/DataSyncMode";
|
|
8
|
-
import { IUser } from "./IUser";
|
|
9
|
-
import { IFlagBase } from "../evaluation";
|
|
10
|
-
|
|
11
|
-
export interface IOptions {
|
|
12
|
-
/**
|
|
13
|
-
* The user for whom you are evaluating feature flags.
|
|
14
|
-
*/
|
|
15
|
-
user?: IUser;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* How long the client constructor will block awaiting a successful connection to FeatBit, in milliseconds.
|
|
19
|
-
*
|
|
20
|
-
* Defaults to 5000 milliseconds.
|
|
21
|
-
*/
|
|
22
|
-
startWaitTime?: number;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The SDK key for your FeatBit environment.
|
|
26
|
-
*/
|
|
27
|
-
sdkKey?: string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The mode to sync flag end segment data with the FeatBit server. See {@link DataSyncModeEnum} for possible values.
|
|
31
|
-
*
|
|
32
|
-
* Defaults to {@link DataSyncModeEnum.STREAMING}.
|
|
33
|
-
*/
|
|
34
|
-
dataSyncMode?: DataSyncModeEnum;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The base URI of the data-sync service, mandatory if the {@link dataSyncMode} is set to {@link DataSyncModeEnum.STREAMING}.
|
|
38
|
-
*/
|
|
39
|
-
streamingUri?: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The base URI of the polling service, mandatory if the {@link dataSyncMode} option is set to {@link DataSyncModeEnum.POLLING}.
|
|
43
|
-
*/
|
|
44
|
-
pollingUri?: string;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The base URI of the event service
|
|
48
|
-
*/
|
|
49
|
-
eventsUri?: string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Whether this client is offline. If true, no calls to FeatBit will be made.
|
|
53
|
-
*
|
|
54
|
-
* Defaults to false
|
|
55
|
-
*/
|
|
56
|
-
offline?: boolean;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The time between polling requests, in milliseconds. Ignored in data-sync mode.
|
|
60
|
-
*
|
|
61
|
-
* Defaults to 30 000 milliseconds.
|
|
62
|
-
*/
|
|
63
|
-
pollingInterval?: number;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The interval in between flushes of events queue, in milliseconds.
|
|
67
|
-
*
|
|
68
|
-
* The default value is 2 000 milliseconds.
|
|
69
|
-
*/
|
|
70
|
-
flushInterval?: number;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The max number of events in the events queue.
|
|
74
|
-
* defaults to 10 000
|
|
75
|
-
*/
|
|
76
|
-
maxEventsInQueue?: number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Configures a logger for warnings and errors generated by the SDK.
|
|
80
|
-
*
|
|
81
|
-
* The logger can be any object that conforms to the {@link ILogger} interface.
|
|
82
|
-
* For a simple implementation that lets you filter by log level, see
|
|
83
|
-
* {@link BasicLogger}. You can also use an instance of `winston.Logger` from
|
|
84
|
-
* the Winston logging package.
|
|
85
|
-
*
|
|
86
|
-
* If you do not set this property, the SDK uses {@link BasicLogger} with a
|
|
87
|
-
* minimum level of `info`.
|
|
88
|
-
*/
|
|
89
|
-
logger?: ILogger;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The interval in between sending WebSocket ping messages to evaluation server, in milliseconds.
|
|
93
|
-
|
|
94
|
-
* Defaults to 18 000 milliseconds.
|
|
95
|
-
*/
|
|
96
|
-
webSocketPingInterval?: number;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* The flags to bootstrap the client, which should be the string representation of type {@link IFlagBase[]}.
|
|
100
|
-
*/
|
|
101
|
-
bootstrap?: IFlagBase[];
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The store to use for caching feature flag data.
|
|
105
|
-
*
|
|
106
|
-
* Defaults to {@link InMemoryStore}.
|
|
107
|
-
*/
|
|
108
|
-
store?: IStore | ((options: IOptions) => IStore);
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* A component that obtains feature flag data and puts it in the store.
|
|
112
|
-
*
|
|
113
|
-
* Defaults to {@link WebSocketDataSynchronizer}.
|
|
114
|
-
*/
|
|
115
|
-
dataSynchronizer?:
|
|
116
|
-
| object
|
|
117
|
-
| ((
|
|
118
|
-
clientContext: IClientContext,
|
|
119
|
-
store: IStore,
|
|
120
|
-
dataSourceUpdates: IDataSourceUpdates,
|
|
121
|
-
initSuccessHandler: VoidFunction,
|
|
122
|
-
errorHandler?: (e: Error) => void,
|
|
123
|
-
) => IDataSynchronizer);
|
|
1
|
+
import { ILogger } from "../logging/ILogger";
|
|
2
|
+
import { IDataSynchronizer } from "../data-sync/IDataSynchronizer";
|
|
3
|
+
import { IClientContext } from "./IClientContext";
|
|
4
|
+
import { IDataSourceUpdates } from "../store/IDataSourceUpdates";
|
|
5
|
+
import { VoidFunction } from "../utils/VoidFunction";
|
|
6
|
+
import { IStore } from "../platform/IStore";
|
|
7
|
+
import { DataSyncModeEnum } from "../data-sync/DataSyncMode";
|
|
8
|
+
import { IUser } from "./IUser";
|
|
9
|
+
import { IFlagBase } from "../evaluation";
|
|
10
|
+
|
|
11
|
+
export interface IOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The user for whom you are evaluating feature flags.
|
|
14
|
+
*/
|
|
15
|
+
user?: IUser;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* How long the client constructor will block awaiting a successful connection to FeatBit, in milliseconds.
|
|
19
|
+
*
|
|
20
|
+
* Defaults to 5000 milliseconds.
|
|
21
|
+
*/
|
|
22
|
+
startWaitTime?: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The SDK key for your FeatBit environment.
|
|
26
|
+
*/
|
|
27
|
+
sdkKey?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The mode to sync flag end segment data with the FeatBit server. See {@link DataSyncModeEnum} for possible values.
|
|
31
|
+
*
|
|
32
|
+
* Defaults to {@link DataSyncModeEnum.STREAMING}.
|
|
33
|
+
*/
|
|
34
|
+
dataSyncMode?: DataSyncModeEnum;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The base URI of the data-sync service, mandatory if the {@link dataSyncMode} is set to {@link DataSyncModeEnum.STREAMING}.
|
|
38
|
+
*/
|
|
39
|
+
streamingUri?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The base URI of the polling service, mandatory if the {@link dataSyncMode} option is set to {@link DataSyncModeEnum.POLLING}.
|
|
43
|
+
*/
|
|
44
|
+
pollingUri?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The base URI of the event service
|
|
48
|
+
*/
|
|
49
|
+
eventsUri?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether this client is offline. If true, no calls to FeatBit will be made.
|
|
53
|
+
*
|
|
54
|
+
* Defaults to false
|
|
55
|
+
*/
|
|
56
|
+
offline?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The time between polling requests, in milliseconds. Ignored in data-sync mode.
|
|
60
|
+
*
|
|
61
|
+
* Defaults to 30 000 milliseconds.
|
|
62
|
+
*/
|
|
63
|
+
pollingInterval?: number;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The interval in between flushes of events queue, in milliseconds.
|
|
67
|
+
*
|
|
68
|
+
* The default value is 2 000 milliseconds.
|
|
69
|
+
*/
|
|
70
|
+
flushInterval?: number;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The max number of events in the events queue.
|
|
74
|
+
* defaults to 10 000
|
|
75
|
+
*/
|
|
76
|
+
maxEventsInQueue?: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Configures a logger for warnings and errors generated by the SDK.
|
|
80
|
+
*
|
|
81
|
+
* The logger can be any object that conforms to the {@link ILogger} interface.
|
|
82
|
+
* For a simple implementation that lets you filter by log level, see
|
|
83
|
+
* {@link BasicLogger}. You can also use an instance of `winston.Logger` from
|
|
84
|
+
* the Winston logging package.
|
|
85
|
+
*
|
|
86
|
+
* If you do not set this property, the SDK uses {@link BasicLogger} with a
|
|
87
|
+
* minimum level of `info`.
|
|
88
|
+
*/
|
|
89
|
+
logger?: ILogger;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The interval in between sending WebSocket ping messages to evaluation server, in milliseconds.
|
|
93
|
+
|
|
94
|
+
* Defaults to 18 000 milliseconds.
|
|
95
|
+
*/
|
|
96
|
+
webSocketPingInterval?: number;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The flags to bootstrap the client, which should be the string representation of type {@link IFlagBase[]}.
|
|
100
|
+
*/
|
|
101
|
+
bootstrap?: IFlagBase[];
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The store to use for caching feature flag data.
|
|
105
|
+
*
|
|
106
|
+
* Defaults to {@link InMemoryStore}.
|
|
107
|
+
*/
|
|
108
|
+
store?: IStore | ((options: IOptions) => IStore);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A component that obtains feature flag data and puts it in the store.
|
|
112
|
+
*
|
|
113
|
+
* Defaults to {@link WebSocketDataSynchronizer}.
|
|
114
|
+
*/
|
|
115
|
+
dataSynchronizer?:
|
|
116
|
+
| object
|
|
117
|
+
| ((
|
|
118
|
+
clientContext: IClientContext,
|
|
119
|
+
store: IStore,
|
|
120
|
+
dataSourceUpdates: IDataSourceUpdates,
|
|
121
|
+
initSuccessHandler: VoidFunction,
|
|
122
|
+
errorHandler?: (e: Error) => void,
|
|
123
|
+
) => IDataSynchronizer);
|
|
124
124
|
}
|
package/src/options/IUser.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IContextProperty } from "../IContextProperty";
|
|
2
|
-
|
|
3
|
-
export interface IUser {
|
|
4
|
-
keyId: string;
|
|
5
|
-
name?: string;
|
|
6
|
-
customizedProperties?: IContextProperty[];
|
|
1
|
+
import { IContextProperty } from "../IContextProperty";
|
|
2
|
+
|
|
3
|
+
export interface IUser {
|
|
4
|
+
keyId: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
customizedProperties?: IContextProperty[];
|
|
7
7
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { ILogger } from "../logging/ILogger";
|
|
2
|
-
import { IStore } from "../platform/IStore";
|
|
3
|
-
import { IOptions } from "./IOptions";
|
|
4
|
-
import { IDataSynchronizer } from "../data-sync/IDataSynchronizer";
|
|
5
|
-
import { DataSyncModeEnum } from "../data-sync/DataSyncMode";
|
|
6
|
-
import { IUser } from "./IUser";
|
|
7
|
-
import { IBootstrapProvider } from "../bootstrap";
|
|
8
|
-
import { IFlagBase } from "../evaluation";
|
|
9
|
-
|
|
10
|
-
export interface IValidatedOptions {
|
|
11
|
-
startWaitTime: number;
|
|
12
|
-
sdkKey: string;
|
|
13
|
-
pollingUri: string;
|
|
14
|
-
streamingUri: string;
|
|
15
|
-
eventsUri: string;
|
|
16
|
-
dataSyncMode: DataSyncModeEnum;
|
|
17
|
-
webSocketPingInterval?: number;
|
|
18
|
-
flushInterval: number;
|
|
19
|
-
maxEventsInQueue: number;
|
|
20
|
-
pollingInterval: number;
|
|
21
|
-
offline: boolean;
|
|
22
|
-
store: IStore | ((options: IOptions) => IStore);
|
|
23
|
-
dataSynchronizer?: IDataSynchronizer;
|
|
24
|
-
logger?: ILogger;
|
|
25
|
-
user?: IUser;
|
|
26
|
-
bootstrap?: IFlagBase[];
|
|
27
|
-
|
|
28
|
-
// Allow indexing this by a string for the validation step.
|
|
29
|
-
[index: string]: any;
|
|
1
|
+
import { ILogger } from "../logging/ILogger";
|
|
2
|
+
import { IStore } from "../platform/IStore";
|
|
3
|
+
import { IOptions } from "./IOptions";
|
|
4
|
+
import { IDataSynchronizer } from "../data-sync/IDataSynchronizer";
|
|
5
|
+
import { DataSyncModeEnum } from "../data-sync/DataSyncMode";
|
|
6
|
+
import { IUser } from "./IUser";
|
|
7
|
+
import { IBootstrapProvider } from "../bootstrap";
|
|
8
|
+
import { IFlagBase } from "../evaluation";
|
|
9
|
+
|
|
10
|
+
export interface IValidatedOptions {
|
|
11
|
+
startWaitTime: number;
|
|
12
|
+
sdkKey: string;
|
|
13
|
+
pollingUri: string;
|
|
14
|
+
streamingUri: string;
|
|
15
|
+
eventsUri: string;
|
|
16
|
+
dataSyncMode: DataSyncModeEnum;
|
|
17
|
+
webSocketPingInterval?: number;
|
|
18
|
+
flushInterval: number;
|
|
19
|
+
maxEventsInQueue: number;
|
|
20
|
+
pollingInterval: number;
|
|
21
|
+
offline: boolean;
|
|
22
|
+
store: IStore | ((options: IOptions) => IStore);
|
|
23
|
+
dataSynchronizer?: IDataSynchronizer;
|
|
24
|
+
logger?: ILogger;
|
|
25
|
+
user?: IUser;
|
|
26
|
+
bootstrap?: IFlagBase[];
|
|
27
|
+
|
|
28
|
+
// Allow indexing this by a string for the validation step.
|
|
29
|
+
[index: string]: any;
|
|
30
30
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Messages for issues which can be encountered from processing the configuration options.
|
|
3
|
-
*/
|
|
4
|
-
export default class OptionMessages {
|
|
5
|
-
static optionBelowMinimum(name: string, value: number, min: number): string {
|
|
6
|
-
return `Config option "${ name }" had invalid value of ${ value }, using minimum of ${ min } instead`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static unknownOption(name: string): string {
|
|
10
|
-
return `Ignoring unknown config option "${ name }"`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static wrongOptionType(name: string, expectedType: string, actualType: string): string {
|
|
14
|
-
return `Config option "${ name }" should be of type ${ expectedType }, got ${ actualType }, using default value`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static wrongOptionTypeBoolean(name: string, actualType: string): string {
|
|
18
|
-
return `Config option "${ name }" should be a boolean, got ${ actualType }, converting to boolean`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static partialEndpoint(name: string): string {
|
|
22
|
-
return `You have set custom uris without specifying the ${ name } URI; connections may not work properly`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static mandatory(name: string): string {
|
|
26
|
-
return `${ name } is mandatory`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static invalidOptionValue(name: string): string {
|
|
30
|
-
return `Invalid option value: ${ name }`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static missingKeyInBootstrapValue(key: string): string {
|
|
34
|
-
return `Missing key "${ key }" in bootstrap value`;
|
|
35
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Messages for issues which can be encountered from processing the configuration options.
|
|
3
|
+
*/
|
|
4
|
+
export default class OptionMessages {
|
|
5
|
+
static optionBelowMinimum(name: string, value: number, min: number): string {
|
|
6
|
+
return `Config option "${ name }" had invalid value of ${ value }, using minimum of ${ min } instead`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static unknownOption(name: string): string {
|
|
10
|
+
return `Ignoring unknown config option "${ name }"`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static wrongOptionType(name: string, expectedType: string, actualType: string): string {
|
|
14
|
+
return `Config option "${ name }" should be of type ${ expectedType }, got ${ actualType }, using default value`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static wrongOptionTypeBoolean(name: string, actualType: string): string {
|
|
18
|
+
return `Config option "${ name }" should be a boolean, got ${ actualType }, converting to boolean`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static partialEndpoint(name: string): string {
|
|
22
|
+
return `You have set custom uris without specifying the ${ name } URI; connections may not work properly`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static mandatory(name: string): string {
|
|
26
|
+
return `${ name } is mandatory`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static invalidOptionValue(name: string): string {
|
|
30
|
+
return `Invalid option value: ${ name }`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static missingKeyInBootstrapValue(key: string): string {
|
|
34
|
+
return `Missing key "${ key }" in bootstrap value`;
|
|
35
|
+
}
|
|
36
36
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { IUser } from "./IUser";
|
|
2
|
-
import {IContextProperty} from "../IContextProperty";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates an instance of the FeatBit user.
|
|
6
|
-
*
|
|
7
|
-
* @return
|
|
8
|
-
* The new {@link IUser} instance.
|
|
9
|
-
*/
|
|
10
|
-
export class UserBuilder {
|
|
11
|
-
private _keyId: string = '';
|
|
12
|
-
private _name: string = '';
|
|
13
|
-
private _custom: IContextProperty[] = [];
|
|
14
|
-
|
|
15
|
-
constructor(keyId: string) {
|
|
16
|
-
this._keyId = keyId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
name(name: string): UserBuilder {
|
|
20
|
-
this._name = name;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
custom(propertyName: string, value: string): UserBuilder {
|
|
25
|
-
this._custom?.push({ name: propertyName, value: `${value}` });
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
build(): IUser {
|
|
30
|
-
return {
|
|
31
|
-
name: this._name,
|
|
32
|
-
keyId: this._keyId,
|
|
33
|
-
customizedProperties: this._custom
|
|
34
|
-
};
|
|
35
|
-
}
|
|
1
|
+
import { IUser } from "./IUser";
|
|
2
|
+
import {IContextProperty} from "../IContextProperty";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates an instance of the FeatBit user.
|
|
6
|
+
*
|
|
7
|
+
* @return
|
|
8
|
+
* The new {@link IUser} instance.
|
|
9
|
+
*/
|
|
10
|
+
export class UserBuilder {
|
|
11
|
+
private _keyId: string = '';
|
|
12
|
+
private _name: string = '';
|
|
13
|
+
private _custom: IContextProperty[] = [];
|
|
14
|
+
|
|
15
|
+
constructor(keyId: string) {
|
|
16
|
+
this._keyId = keyId;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
name(name: string): UserBuilder {
|
|
20
|
+
this._name = name;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
custom(propertyName: string, value: string): UserBuilder {
|
|
25
|
+
this._custom?.push({ name: propertyName, value: `${value}` });
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
build(): IUser {
|
|
30
|
+
return {
|
|
31
|
+
name: this._name,
|
|
32
|
+
keyId: this._keyId,
|
|
33
|
+
customizedProperties: this._custom
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
36
|
}
|