@featbit/js-client-sdk 2.0.2 → 3.0.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/LICENSE +21 -201
- package/README.md +160 -152
- package/dist/esm/Configuration.d.ts +35 -0
- package/dist/esm/Configuration.d.ts.map +1 -0
- package/dist/esm/Configuration.js +179 -0
- package/dist/esm/Configuration.js.map +1 -0
- package/dist/esm/Context.d.ts +23 -0
- package/dist/esm/Context.d.ts.map +1 -0
- package/dist/esm/Context.js +49 -0
- package/dist/esm/Context.js.map +1 -0
- package/dist/esm/FbClientBuilder.d.ts +90 -0
- package/dist/esm/FbClientBuilder.d.ts.map +1 -0
- package/dist/esm/FbClientBuilder.js +133 -0
- package/dist/esm/FbClientBuilder.js.map +1 -0
- package/dist/esm/FbClientCore.d.ts +56 -0
- package/dist/esm/FbClientCore.d.ts.map +1 -0
- package/dist/esm/FbClientCore.js +283 -0
- package/dist/esm/FbClientCore.js.map +1 -0
- package/dist/esm/IContextProperty.d.ts +5 -0
- package/dist/esm/IContextProperty.d.ts.map +1 -0
- package/dist/esm/IContextProperty.js +3 -0
- package/dist/esm/IContextProperty.js.map +1 -0
- package/dist/esm/IDataKind.d.ts +12 -0
- package/dist/esm/IDataKind.d.ts.map +1 -0
- package/dist/esm/IDataKind.js +3 -0
- package/dist/esm/IDataKind.js.map +1 -0
- package/dist/esm/IFbClient.d.ts +30 -0
- package/dist/esm/IFbClient.d.ts.map +1 -0
- package/dist/esm/IFbClient.js +3 -0
- package/dist/esm/IFbClient.js.map +1 -0
- package/dist/esm/IFbClientCore.d.ts +240 -0
- package/dist/esm/IFbClientCore.d.ts.map +1 -0
- package/dist/esm/IFbClientCore.js +3 -0
- package/dist/esm/IFbClientCore.js.map +1 -0
- package/dist/esm/IVersionedData.d.ts +18 -0
- package/dist/esm/IVersionedData.d.ts.map +1 -0
- package/dist/esm/IVersionedData.js +3 -0
- package/dist/esm/IVersionedData.js.map +1 -0
- package/dist/esm/bootstrap/IBootstrapProvider.d.ts +5 -0
- package/dist/esm/bootstrap/IBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/IBootstrapProvider.js +3 -0
- package/dist/esm/bootstrap/IBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.d.ts +9 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.js +29 -0
- package/dist/esm/bootstrap/JsonBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.d.ts +8 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.d.ts.map +1 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.js +19 -0
- package/dist/esm/bootstrap/NullBootstrapProvider.js.map +1 -0
- package/dist/esm/bootstrap/index.d.ts +4 -0
- package/dist/esm/bootstrap/index.d.ts.map +1 -0
- package/dist/esm/bootstrap/index.js +20 -0
- package/dist/esm/bootstrap/index.js.map +1 -0
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/data-sources/DataSourceUpdates.d.ts +17 -0
- package/dist/esm/data-sources/DataSourceUpdates.d.ts.map +1 -0
- package/dist/esm/data-sources/DataSourceUpdates.js +84 -0
- package/dist/esm/data-sources/DataSourceUpdates.js.map +1 -0
- package/dist/esm/data-sources/createStreamListeners.d.ts +19 -0
- package/dist/esm/data-sources/createStreamListeners.d.ts.map +1 -0
- package/dist/esm/data-sources/createStreamListeners.js +49 -0
- package/dist/esm/data-sources/createStreamListeners.js.map +1 -0
- package/dist/esm/data-sources/index.d.ts +3 -0
- package/dist/esm/data-sources/index.d.ts.map +1 -0
- package/dist/esm/data-sources/index.js +19 -0
- package/dist/esm/data-sources/index.js.map +1 -0
- package/dist/esm/data-sync/DataSyncMode.d.ts +5 -0
- package/dist/esm/data-sync/DataSyncMode.d.ts.map +1 -0
- package/dist/esm/data-sync/DataSyncMode.js +9 -0
- package/dist/esm/data-sync/DataSyncMode.js.map +1 -0
- package/dist/esm/data-sync/IDataSynchronizer.d.ts +15 -0
- package/dist/esm/data-sync/IDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/IDataSynchronizer.js +3 -0
- package/dist/esm/data-sync/IDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/IRequestor.d.ts +11 -0
- package/dist/esm/data-sync/IRequestor.d.ts.map +1 -0
- package/dist/esm/data-sync/IRequestor.js +3 -0
- package/dist/esm/data-sync/IRequestor.js.map +1 -0
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts +8 -0
- package/dist/esm/data-sync/NullDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js +15 -0
- package/dist/esm/data-sync/NullDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts +23 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.js +87 -0
- package/dist/esm/data-sync/PollingDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/Requestor.d.ts +20 -0
- package/dist/esm/data-sync/Requestor.d.ts.map +1 -0
- package/dist/esm/data-sync/Requestor.js +56 -0
- package/dist/esm/data-sync/Requestor.js.map +1 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts +20 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js +55 -0
- package/dist/esm/data-sync/WebSocketDataSynchronizer.js.map +1 -0
- package/dist/esm/data-sync/index.d.ts +10 -0
- package/dist/esm/data-sync/index.d.ts.map +1 -0
- package/dist/esm/data-sync/index.js +26 -0
- package/dist/esm/data-sync/index.js.map +1 -0
- package/dist/esm/data-sync/types.d.ts +17 -0
- package/dist/esm/data-sync/types.d.ts.map +1 -0
- package/dist/esm/data-sync/types.js +9 -0
- package/dist/esm/data-sync/types.js.map +1 -0
- package/dist/esm/data-sync/utils.d.ts +3 -0
- package/dist/esm/data-sync/utils.d.ts.map +1 -0
- package/dist/esm/data-sync/utils.js +33 -0
- package/dist/esm/data-sync/utils.js.map +1 -0
- package/dist/esm/errors.d.ts +16 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +41 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/evaluation/EvalResult.d.ts +20 -0
- package/dist/esm/evaluation/EvalResult.d.ts.map +1 -0
- package/dist/esm/evaluation/EvalResult.js +33 -0
- package/dist/esm/evaluation/EvalResult.js.map +1 -0
- package/dist/esm/evaluation/Evaluator.d.ts +15 -0
- package/dist/esm/evaluation/Evaluator.d.ts.map +1 -0
- package/dist/esm/evaluation/Evaluator.js +28 -0
- package/dist/esm/evaluation/Evaluator.js.map +1 -0
- package/dist/esm/evaluation/IEvalDetail.d.ts +21 -0
- package/dist/esm/evaluation/IEvalDetail.d.ts.map +1 -0
- package/dist/esm/evaluation/IEvalDetail.js +3 -0
- package/dist/esm/evaluation/IEvalDetail.js.map +1 -0
- package/dist/esm/evaluation/ReasonKinds.d.ts +11 -0
- package/dist/esm/evaluation/ReasonKinds.d.ts.map +1 -0
- package/dist/esm/evaluation/ReasonKinds.js +15 -0
- package/dist/esm/evaluation/ReasonKinds.js.map +1 -0
- package/dist/esm/evaluation/data/IFlag.d.ts +26 -0
- package/dist/esm/evaluation/data/IFlag.d.ts.map +1 -0
- package/dist/esm/evaluation/data/IFlag.js +12 -0
- package/dist/esm/evaluation/data/IFlag.js.map +1 -0
- package/dist/esm/evaluation/data/index.d.ts +2 -0
- package/dist/esm/evaluation/data/index.d.ts.map +1 -0
- package/dist/esm/evaluation/data/index.js +18 -0
- package/dist/esm/evaluation/data/index.js.map +1 -0
- package/dist/esm/evaluation/index.d.ts +6 -0
- package/dist/esm/evaluation/index.d.ts.map +1 -0
- package/dist/esm/evaluation/index.js +22 -0
- package/dist/esm/evaluation/index.js.map +1 -0
- package/dist/esm/events/DefaultEventProcessor.d.ts +16 -0
- package/dist/esm/events/DefaultEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventProcessor.js +79 -0
- package/dist/esm/events/DefaultEventProcessor.js.map +1 -0
- package/dist/esm/events/DefaultEventQueue.d.ts +18 -0
- package/dist/esm/events/DefaultEventQueue.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventQueue.js +42 -0
- package/dist/esm/events/DefaultEventQueue.js.map +1 -0
- package/dist/esm/events/DefaultEventSender.d.ts +10 -0
- package/dist/esm/events/DefaultEventSender.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventSender.js +67 -0
- package/dist/esm/events/DefaultEventSender.js.map +1 -0
- package/dist/esm/events/DefaultEventSerializer.d.ts +6 -0
- package/dist/esm/events/DefaultEventSerializer.d.ts.map +1 -0
- package/dist/esm/events/DefaultEventSerializer.js +14 -0
- package/dist/esm/events/DefaultEventSerializer.js.map +1 -0
- package/dist/esm/events/EventDispatcher.d.ts +17 -0
- package/dist/esm/events/EventDispatcher.d.ts.map +1 -0
- package/dist/esm/events/EventDispatcher.js +127 -0
- package/dist/esm/events/EventDispatcher.js.map +1 -0
- package/dist/esm/events/EventSerializer.d.ts +5 -0
- package/dist/esm/events/EventSerializer.d.ts.map +1 -0
- package/dist/esm/events/EventSerializer.js +3 -0
- package/dist/esm/events/EventSerializer.js.map +1 -0
- package/dist/esm/events/IEventProcessor.d.ts +7 -0
- package/dist/esm/events/IEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/IEventProcessor.js +3 -0
- package/dist/esm/events/IEventProcessor.js.map +1 -0
- package/dist/esm/events/IEventQueue.d.ts +11 -0
- package/dist/esm/events/IEventQueue.d.ts.map +1 -0
- package/dist/esm/events/IEventQueue.js +3 -0
- package/dist/esm/events/IEventQueue.js.map +1 -0
- package/dist/esm/events/IEventSender.d.ts +13 -0
- package/dist/esm/events/IEventSender.d.ts.map +1 -0
- package/dist/esm/events/IEventSender.js +10 -0
- package/dist/esm/events/IEventSender.js.map +1 -0
- package/dist/esm/events/NullEventProcessor.d.ts +8 -0
- package/dist/esm/events/NullEventProcessor.d.ts.map +1 -0
- package/dist/esm/events/NullEventProcessor.js +16 -0
- package/dist/esm/events/NullEventProcessor.js.map +1 -0
- package/dist/esm/events/event.d.ts +44 -0
- package/dist/esm/events/event.d.ts.map +1 -0
- package/dist/esm/events/event.js +115 -0
- package/dist/esm/events/event.js.map +1 -0
- package/dist/esm/events/index.d.ts +12 -0
- package/dist/esm/events/index.d.ts.map +1 -0
- package/dist/esm/events/index.js +28 -0
- package/dist/esm/events/index.js.map +1 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +36 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/integrations/TestLogger.d.ts +10 -0
- package/dist/esm/integrations/TestLogger.d.ts.map +1 -0
- package/dist/esm/integrations/TestLogger.js +25 -0
- package/dist/esm/integrations/TestLogger.js.map +1 -0
- package/dist/esm/integrations/index.d.ts +3 -0
- package/dist/esm/integrations/index.d.ts.map +1 -0
- package/dist/esm/integrations/index.js +21 -0
- package/dist/esm/integrations/index.js.map +1 -0
- package/dist/esm/integrations/test_data/FlagBuilder.d.ts +19 -0
- package/dist/esm/integrations/test_data/FlagBuilder.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/FlagBuilder.js +56 -0
- package/dist/esm/integrations/test_data/FlagBuilder.js.map +1 -0
- package/dist/esm/integrations/test_data/TestData.d.ts +18 -0
- package/dist/esm/integrations/test_data/TestData.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/TestData.js +38 -0
- package/dist/esm/integrations/test_data/TestData.js.map +1 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts +21 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js +50 -0
- package/dist/esm/integrations/test_data/TestDataSynchronizer.js.map +1 -0
- package/dist/esm/integrations/test_data/index.d.ts +5 -0
- package/dist/esm/integrations/test_data/index.d.ts.map +1 -0
- package/dist/esm/integrations/test_data/index.js +13 -0
- package/dist/esm/integrations/test_data/index.js.map +1 -0
- package/dist/esm/logging/BasicLogger.d.ts +34 -0
- package/dist/esm/logging/BasicLogger.d.ts.map +1 -0
- package/dist/esm/logging/BasicLogger.js +101 -0
- package/dist/esm/logging/BasicLogger.js.map +1 -0
- package/dist/esm/logging/IBasicLoggerOptions.d.ts +43 -0
- package/dist/esm/logging/IBasicLoggerOptions.d.ts.map +1 -0
- package/dist/esm/logging/IBasicLoggerOptions.js +3 -0
- package/dist/esm/logging/IBasicLoggerOptions.js.map +1 -0
- package/dist/esm/logging/ILogger.d.ts +47 -0
- package/dist/esm/logging/ILogger.d.ts.map +1 -0
- package/dist/esm/logging/ILogger.js +3 -0
- package/dist/esm/logging/ILogger.js.map +1 -0
- package/dist/esm/logging/LogLevel.d.ts +10 -0
- package/dist/esm/logging/LogLevel.d.ts.map +1 -0
- package/dist/esm/logging/LogLevel.js +3 -0
- package/dist/esm/logging/LogLevel.js.map +1 -0
- package/dist/esm/logging/SafeLogger.d.ts +28 -0
- package/dist/esm/logging/SafeLogger.d.ts.map +1 -0
- package/dist/esm/logging/SafeLogger.js +63 -0
- package/dist/esm/logging/SafeLogger.js.map +1 -0
- package/dist/esm/logging/format.d.ts +12 -0
- package/dist/esm/logging/format.d.ts.map +1 -0
- package/dist/esm/logging/format.js +156 -0
- package/dist/esm/logging/format.js.map +1 -0
- package/dist/esm/logging/index.d.ts +7 -0
- package/dist/esm/logging/index.d.ts.map +1 -0
- package/dist/esm/logging/index.js +23 -0
- package/dist/esm/logging/index.js.map +1 -0
- package/dist/esm/options/ClientContext.d.ts +28 -0
- package/dist/esm/options/ClientContext.d.ts.map +1 -0
- package/dist/esm/options/ClientContext.js +21 -0
- package/dist/esm/options/ClientContext.js.map +1 -0
- package/dist/esm/options/IClientContext.d.ts +45 -0
- package/dist/esm/options/IClientContext.d.ts.map +1 -0
- package/dist/esm/options/IClientContext.js +3 -0
- package/dist/esm/options/IClientContext.js.map +1 -0
- package/dist/esm/options/IOptions.d.ts +101 -0
- package/dist/esm/options/IOptions.d.ts.map +1 -0
- package/dist/esm/options/IOptions.js +3 -0
- package/dist/esm/options/IOptions.js.map +1 -0
- package/dist/esm/options/IUser.d.ts +7 -0
- package/dist/esm/options/IUser.d.ts.map +1 -0
- package/dist/esm/options/IUser.js +3 -0
- package/dist/esm/options/IUser.js.map +1 -0
- package/dist/esm/options/IValidatedOptions.d.ts +27 -0
- package/dist/esm/options/IValidatedOptions.d.ts.map +1 -0
- package/dist/esm/options/IValidatedOptions.js +3 -0
- package/dist/esm/options/IValidatedOptions.js.map +1 -0
- package/dist/esm/options/OptionMessages.d.ts +14 -0
- package/dist/esm/options/OptionMessages.d.ts.map +1 -0
- package/dist/esm/options/OptionMessages.js +33 -0
- package/dist/esm/options/OptionMessages.js.map +1 -0
- package/dist/esm/options/UserBuilder.d.ts +17 -0
- package/dist/esm/options/UserBuilder.d.ts.map +1 -0
- package/dist/esm/options/UserBuilder.js +35 -0
- package/dist/esm/options/UserBuilder.js.map +1 -0
- package/dist/esm/options/Validators.d.ts +111 -0
- package/dist/esm/options/Validators.d.ts.map +1 -0
- package/dist/esm/options/Validators.js +247 -0
- package/dist/esm/options/Validators.js.map +1 -0
- package/dist/esm/options/index.d.ts +9 -0
- package/dist/esm/options/index.d.ts.map +1 -0
- package/dist/esm/options/index.js +25 -0
- package/dist/esm/options/index.js.map +1 -0
- package/dist/esm/platform/IInfo.d.ts +73 -0
- package/dist/esm/platform/IInfo.d.ts.map +1 -0
- package/dist/esm/platform/IInfo.js +3 -0
- package/dist/esm/platform/IInfo.js.map +1 -0
- package/dist/esm/platform/IPlatform.d.ts +19 -0
- package/dist/esm/platform/IPlatform.d.ts.map +1 -0
- package/dist/esm/platform/IPlatform.js +3 -0
- package/dist/esm/platform/IPlatform.js.map +1 -0
- package/dist/esm/platform/IStore.d.ts +110 -0
- package/dist/esm/platform/IStore.d.ts.map +1 -0
- package/dist/esm/platform/IStore.js +3 -0
- package/dist/esm/platform/IStore.js.map +1 -0
- package/dist/esm/platform/IWebSocket.d.ts +21 -0
- package/dist/esm/platform/IWebSocket.d.ts.map +1 -0
- package/dist/esm/platform/IWebSocket.js +3 -0
- package/dist/esm/platform/IWebSocket.js.map +1 -0
- package/dist/esm/platform/browser/BrowserInfo.d.ts +7 -0
- package/dist/esm/platform/browser/BrowserInfo.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserInfo.js +24 -0
- package/dist/esm/platform/browser/BrowserInfo.js.map +1 -0
- package/dist/esm/platform/browser/BrowserPlatform.d.ts +12 -0
- package/dist/esm/platform/browser/BrowserPlatform.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserPlatform.js +17 -0
- package/dist/esm/platform/browser/BrowserPlatform.js.map +1 -0
- package/dist/esm/platform/browser/BrowserRequests.d.ts +5 -0
- package/dist/esm/platform/browser/BrowserRequests.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserRequests.js +9 -0
- package/dist/esm/platform/browser/BrowserRequests.js.map +1 -0
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts +38 -0
- package/dist/esm/platform/browser/BrowserWebSocket.d.ts.map +1 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js +129 -0
- package/dist/esm/platform/browser/BrowserWebSocket.js.map +1 -0
- package/dist/esm/platform/browser/FbClient.d.ts +30 -0
- package/dist/esm/platform/browser/FbClient.d.ts.map +1 -0
- package/dist/esm/platform/browser/FbClient.js +47 -0
- package/dist/esm/platform/browser/FbClient.js.map +1 -0
- package/dist/esm/platform/browser/LocalStorageStore.d.ts +26 -0
- package/dist/esm/platform/browser/LocalStorageStore.d.ts.map +1 -0
- package/dist/esm/platform/browser/LocalStorageStore.js +122 -0
- package/dist/esm/platform/browser/LocalStorageStore.js.map +1 -0
- package/dist/esm/platform/index.d.ts +5 -0
- package/dist/esm/platform/index.d.ts.map +1 -0
- package/dist/esm/platform/index.js +21 -0
- package/dist/esm/platform/index.js.map +1 -0
- package/dist/esm/platform/requests.d.ts +64 -0
- package/dist/esm/platform/requests.d.ts.map +1 -0
- package/dist/esm/platform/requests.js +7 -0
- package/dist/esm/platform/requests.js.map +1 -0
- package/dist/esm/store/DataKinds.d.ts +5 -0
- package/dist/esm/store/DataKinds.d.ts.map +1 -0
- package/dist/esm/store/DataKinds.js +9 -0
- package/dist/esm/store/DataKinds.js.map +1 -0
- package/dist/esm/store/IDataSourceUpdates.d.ts +48 -0
- package/dist/esm/store/IDataSourceUpdates.d.ts.map +1 -0
- package/dist/esm/store/IDataSourceUpdates.js +3 -0
- package/dist/esm/store/IDataSourceUpdates.js.map +1 -0
- package/dist/esm/store/InMemoryStore.d.ts +24 -0
- package/dist/esm/store/InMemoryStore.d.ts.map +1 -0
- package/dist/esm/store/InMemoryStore.js +96 -0
- package/dist/esm/store/InMemoryStore.js.map +1 -0
- package/dist/esm/store/index.d.ts +6 -0
- package/dist/esm/store/index.d.ts.map +1 -0
- package/dist/esm/store/index.js +22 -0
- package/dist/esm/store/index.js.map +1 -0
- package/dist/esm/store/serialization.d.ts +23 -0
- package/dist/esm/store/serialization.d.ts.map +1 -0
- package/dist/esm/store/serialization.js +37 -0
- package/dist/esm/store/serialization.js.map +1 -0
- package/dist/esm/store/store.d.ts +30 -0
- package/dist/esm/store/store.d.ts.map +1 -0
- package/dist/esm/store/store.js +6 -0
- package/dist/esm/store/store.js.map +1 -0
- package/dist/esm/utils/Emits.d.ts +30 -0
- package/dist/esm/utils/Emits.d.ts.map +1 -0
- package/dist/esm/utils/Emits.js +64 -0
- package/dist/esm/utils/Emits.js.map +1 -0
- package/dist/esm/utils/EventEmitter.d.ts +22 -0
- package/dist/esm/utils/EventEmitter.d.ts.map +1 -0
- package/dist/esm/utils/EventEmitter.js +108 -0
- package/dist/esm/utils/EventEmitter.js.map +1 -0
- package/dist/esm/utils/IEventEmitter.d.ts +16 -0
- package/dist/esm/utils/IEventEmitter.d.ts.map +1 -0
- package/dist/esm/utils/IEventEmitter.js +3 -0
- package/dist/esm/utils/IEventEmitter.js.map +1 -0
- package/dist/esm/utils/Regex.d.ts +7 -0
- package/dist/esm/utils/Regex.d.ts.map +1 -0
- package/dist/esm/utils/Regex.js +22 -0
- package/dist/esm/utils/Regex.js.map +1 -0
- package/dist/esm/utils/ValueConverters.d.ts +13 -0
- package/dist/esm/utils/ValueConverters.d.ts.map +1 -0
- package/dist/esm/utils/ValueConverters.js +46 -0
- package/dist/esm/utils/ValueConverters.js.map +1 -0
- package/dist/esm/utils/VoidFunction.d.ts +2 -0
- package/dist/esm/utils/VoidFunction.d.ts.map +1 -0
- package/dist/esm/utils/VoidFunction.js +3 -0
- package/dist/esm/utils/VoidFunction.js.map +1 -0
- package/dist/esm/utils/canonicalizeUri.d.ts +2 -0
- package/dist/esm/utils/canonicalizeUri.d.ts.map +1 -0
- package/dist/esm/utils/canonicalizeUri.js +9 -0
- package/dist/esm/utils/canonicalizeUri.js.map +1 -0
- package/dist/esm/utils/http.d.ts +12 -0
- package/dist/esm/utils/http.d.ts.map +1 -0
- package/dist/esm/utils/http.js +26 -0
- package/dist/esm/utils/http.js.map +1 -0
- package/dist/esm/utils/index.d.ts +5 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +21 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/isNullOrUndefined.d.ts +2 -0
- package/dist/esm/utils/isNullOrUndefined.d.ts.map +1 -0
- package/dist/esm/utils/isNullOrUndefined.js +8 -0
- package/dist/esm/utils/isNullOrUndefined.js.map +1 -0
- package/dist/esm/utils/serializeUser.d.ts +3 -0
- package/dist/esm/utils/serializeUser.d.ts.map +1 -0
- package/dist/esm/utils/serializeUser.js +24 -0
- package/dist/esm/utils/serializeUser.js.map +1 -0
- package/dist/esm/utils/sleep.d.ts +3 -0
- package/dist/esm/utils/sleep.d.ts.map +1 -0
- package/dist/esm/utils/sleep.js +18 -0
- package/dist/esm/utils/sleep.js.map +1 -0
- package/dist/esm/version.d.ts +3 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk-3.0.0.js +2 -0
- package/dist/umd/featbit-js-client-sdk-3.0.0.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk.js +2 -0
- package/dist/umd/featbit-js-client-sdk.js.map +1 -0
- package/package.json +22 -24
- package/src/Configuration.ts +234 -0
- package/src/Context.ts +62 -0
- package/src/FbClientBuilder.ts +161 -0
- package/src/FbClientCore.ts +389 -0
- package/src/IContextProperty.ts +4 -0
- package/src/IDataKind.ts +11 -0
- package/src/IFbClient.ts +30 -0
- package/src/IFbClientCore.ts +291 -0
- package/src/IVersionedData.ts +18 -0
- package/src/bootstrap/IBootstrapProvider.ts +5 -0
- package/src/bootstrap/JsonBootstrapProvider.ts +35 -0
- package/src/bootstrap/NullBootstrapProvider.ts +21 -0
- package/src/bootstrap/index.ts +3 -0
- package/src/constants.ts +2 -6
- package/src/data-sources/DataSourceUpdates.ts +93 -0
- package/src/data-sources/createStreamListeners.ts +66 -0
- package/src/data-sources/index.ts +2 -0
- package/src/data-sync/DataSyncMode.ts +4 -0
- package/src/data-sync/IDataSynchronizer.ts +15 -0
- package/src/data-sync/IRequestor.ts +10 -0
- package/src/data-sync/NullDataSynchronizer.ts +15 -0
- package/src/data-sync/PollingDataSynchronizer.ts +111 -0
- package/src/data-sync/Requestor.ts +61 -0
- package/src/data-sync/WebSocketDataSynchronizer.ts +74 -0
- package/src/data-sync/index.ts +9 -0
- package/src/data-sync/types.ts +20 -0
- package/src/data-sync/utils.ts +32 -0
- package/src/errors.ts +41 -0
- package/src/evaluation/EvalResult.ts +36 -0
- package/src/evaluation/Evaluator.ts +27 -0
- package/src/evaluation/IEvalDetail.ts +24 -0
- package/src/evaluation/ReasonKinds.ts +10 -0
- package/src/evaluation/data/IFlag.ts +29 -0
- package/src/evaluation/data/index.ts +1 -0
- package/src/evaluation/index.ts +5 -0
- package/src/events/DefaultEventProcessor.ts +84 -0
- package/src/events/DefaultEventQueue.ts +50 -0
- package/src/events/DefaultEventSender.ts +75 -0
- package/src/events/DefaultEventSerializer.ts +12 -0
- package/src/events/EventDispatcher.ts +128 -0
- package/src/events/EventSerializer.ts +5 -0
- package/src/events/IEventProcessor.ts +9 -0
- package/src/events/IEventQueue.ts +17 -0
- package/src/events/IEventSender.ts +14 -0
- package/src/events/NullEventProcessor.ts +16 -0
- package/src/events/event.ts +130 -0
- package/src/events/index.ts +11 -0
- package/src/index.ts +19 -4
- package/src/integrations/TestLogger.ts +25 -0
- package/src/integrations/index.ts +2 -0
- package/src/integrations/test_data/FlagBuilder.ts +60 -0
- package/src/integrations/test_data/TestData.ts +58 -0
- package/src/integrations/test_data/TestDataSynchronizer.ts +50 -0
- package/src/integrations/test_data/index.ts +5 -0
- package/src/logging/BasicLogger.ts +108 -0
- package/src/logging/IBasicLoggerOptions.ts +46 -0
- package/src/logging/ILogger.ts +49 -0
- package/src/logging/LogLevel.ts +9 -0
- package/src/logging/SafeLogger.ts +70 -0
- package/src/logging/format.ts +154 -0
- package/src/logging/index.ts +6 -0
- package/src/options/ClientContext.ts +40 -0
- package/src/options/IClientContext.ts +54 -0
- package/src/options/IOptions.ts +124 -0
- package/src/options/IUser.ts +7 -0
- package/src/options/IValidatedOptions.ts +30 -0
- package/src/options/OptionMessages.ts +36 -0
- package/src/options/UserBuilder.ts +36 -0
- package/src/options/Validators.ts +301 -0
- package/src/options/index.ts +8 -0
- package/src/platform/IInfo.ts +82 -0
- package/src/platform/IPlatform.ts +21 -0
- package/src/platform/IStore.ts +119 -0
- package/src/platform/IWebSocket.ts +23 -0
- package/src/platform/browser/BrowserInfo.ts +25 -0
- package/src/platform/browser/BrowserPlatform.ts +20 -0
- package/src/platform/browser/BrowserRequests.ts +7 -0
- package/src/platform/browser/BrowserWebSocket.ts +143 -0
- package/src/platform/browser/FbClient.ts +59 -0
- package/src/platform/browser/LocalStorageStore.ts +153 -0
- package/src/platform/index.ts +4 -0
- package/src/platform/requests.ts +77 -0
- package/src/store/DataKinds.ts +7 -0
- package/src/store/IDataSourceUpdates.ts +49 -0
- package/src/store/InMemoryStore.ts +115 -0
- package/src/store/index.ts +5 -0
- package/src/store/serialization.ts +52 -0
- package/src/store/store.ts +38 -0
- package/src/utils/Emits.ts +76 -0
- package/src/utils/EventEmitter.ts +129 -0
- package/src/utils/IEventEmitter.ts +15 -0
- package/src/utils/Regex.ts +22 -0
- package/src/utils/ValueConverters.ts +56 -0
- package/src/utils/VoidFunction.ts +1 -0
- package/src/utils/canonicalizeUri.ts +4 -0
- package/src/utils/http.ts +40 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/isNullOrUndefined.ts +3 -0
- package/src/utils/serializeUser.ts +28 -0
- package/src/utils/sleep.ts +6 -0
- package/src/version.ts +1 -0
- package/esm/constants.d.ts +0 -6
- package/esm/constants.js +0 -7
- package/esm/constants.js.map +0 -1
- package/esm/events.d.ts +0 -14
- package/esm/events.js +0 -27
- package/esm/events.js.map +0 -1
- package/esm/featbit.d.ts +0 -34
- package/esm/featbit.js +0 -382
- package/esm/featbit.js.map +0 -1
- package/esm/index.d.ts +0 -4
- package/esm/index.js +0 -5
- package/esm/index.js.map +0 -1
- package/esm/logger.d.ts +0 -4
- package/esm/logger.js +0 -20
- package/esm/logger.js.map +0 -1
- package/esm/network.service.d.ts +0 -27
- package/esm/network.service.js +0 -288
- package/esm/network.service.js.map +0 -1
- package/esm/optionMessages.d.ts +0 -5
- package/esm/optionMessages.js +0 -16
- package/esm/optionMessages.js.map +0 -1
- package/esm/queue.d.ts +0 -8
- package/esm/queue.js +0 -35
- package/esm/queue.js.map +0 -1
- package/esm/store.d.ts +0 -20
- package/esm/store.js +0 -143
- package/esm/store.js.map +0 -1
- package/esm/throttleutil.d.ts +0 -9
- package/esm/throttleutil.js +0 -133
- package/esm/throttleutil.js.map +0 -1
- package/esm/types.d.ts +0 -94
- package/esm/types.js +0 -24
- package/esm/types.js.map +0 -1
- package/esm/umd.d.ts +0 -2
- package/esm/utils.d.ts +0 -11
- package/esm/utils.js +0 -142
- package/esm/utils.js.map +0 -1
- package/src/events.ts +0 -29
- package/src/featbit.ts +0 -343
- package/src/logger.ts +0 -13
- package/src/network.service.ts +0 -223
- package/src/optionMessages.ts +0 -13
- package/src/queue.ts +0 -23
- package/src/store.ts +0 -169
- package/src/throttleutil.ts +0 -72
- package/src/types.ts +0 -113
- package/src/umd.ts +0 -15
- package/src/utils.ts +0 -173
- package/umd/featbit-js-client-sdk-2.0.2.js +0 -2
- package/umd/featbit-js-client-sdk-2.0.2.js.map +0 -1
- package/umd/featbit-js-client-sdk.js +0 -2
- package/umd/featbit-js-client-sdk.js.map +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import format from './format';
|
|
2
|
+
import { ILogger } from "./ILogger";
|
|
3
|
+
import { IBasicLoggerOptions } from "./IBasicLoggerOptions";
|
|
4
|
+
|
|
5
|
+
const LogPriority = {
|
|
6
|
+
debug: 0,
|
|
7
|
+
info: 1,
|
|
8
|
+
warn: 2,
|
|
9
|
+
error: 3,
|
|
10
|
+
none: 4,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const LevelNames = ['debug', 'info', 'warn', 'error', 'none'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A basic logger which handles filtering by level.
|
|
17
|
+
*
|
|
18
|
+
* With the default options it will write to `console.error`
|
|
19
|
+
* and it will use the formatting provided by `console.error`.
|
|
20
|
+
* If the destination is overwritten, then it will use an included
|
|
21
|
+
* formatter similar to `util.format`.
|
|
22
|
+
*
|
|
23
|
+
* If a formatter is available, then that should be overridden
|
|
24
|
+
* as well for performance.
|
|
25
|
+
*/
|
|
26
|
+
export class BasicLogger implements ILogger {
|
|
27
|
+
private logLevel: number;
|
|
28
|
+
|
|
29
|
+
private name: string;
|
|
30
|
+
|
|
31
|
+
private destination?: (line: string) => void;
|
|
32
|
+
|
|
33
|
+
private formatter?: (...args: any[]) => string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This should only be used as a default fallback and not as a convenient
|
|
37
|
+
* solution. In most cases you should construct a new instance with the
|
|
38
|
+
* appropriate options for your specific needs.
|
|
39
|
+
*/
|
|
40
|
+
static get() {
|
|
41
|
+
return new BasicLogger({});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor(options: IBasicLoggerOptions) {
|
|
45
|
+
this.logLevel = LogPriority[options.level ?? 'info'] ?? LogPriority.info;
|
|
46
|
+
this.name = options.name ?? 'FeatBit';
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
this.destination = options.destination;
|
|
49
|
+
this.formatter = options.formatter;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private tryFormat(...args: any[]): string {
|
|
53
|
+
try {
|
|
54
|
+
if (this.formatter) {
|
|
55
|
+
// In case the provided formatter fails.
|
|
56
|
+
return this.formatter?.(...args);
|
|
57
|
+
}
|
|
58
|
+
return format(...args);
|
|
59
|
+
} catch {
|
|
60
|
+
return format(...args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private tryWrite(msg: string) {
|
|
65
|
+
try {
|
|
66
|
+
this.destination!(msg);
|
|
67
|
+
} catch {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.error(msg);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private log(level: number, args: any[]) {
|
|
74
|
+
if (level >= this.logLevel) {
|
|
75
|
+
const prefix = `${ LevelNames[level] }: [${ this.name }]`;
|
|
76
|
+
try {
|
|
77
|
+
if (this.destination) {
|
|
78
|
+
this.tryWrite(`${ prefix } ${ this.tryFormat(...args) }`);
|
|
79
|
+
} else {
|
|
80
|
+
// `console.error` has its own formatter.
|
|
81
|
+
// So we don't need to do anything.
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.error(...args);
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// If all else fails do not break.
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.error(...args);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
error(...args: any[]): void {
|
|
94
|
+
this.log(LogPriority.error, args);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
warn(...args: any[]): void {
|
|
98
|
+
this.log(LogPriority.warn, args);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
info(...args: any[]): void {
|
|
102
|
+
this.log(LogPriority.info, args);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
debug(...args: any[]): void {
|
|
106
|
+
this.log(LogPriority.debug, args);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ILogLevel } from './LogLevel';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link basicLogger}.
|
|
5
|
+
*/
|
|
6
|
+
export interface IBasicLoggerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The lowest level of log message to enable.
|
|
9
|
+
*
|
|
10
|
+
* See {@link ILogLevel} for a list of possible levels. Setting a level here causes
|
|
11
|
+
* all lower-importance levels to be disabled: for instance, if you specify
|
|
12
|
+
* `'warn'`, then `'debug'` and `'info'` are disabled.
|
|
13
|
+
*
|
|
14
|
+
* If not specified, the default is `'info'` (meaning that `'debug'` is disabled).
|
|
15
|
+
*/
|
|
16
|
+
level?: ILogLevel;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Name to use for the log entires. The default name is `FeatBit`.
|
|
20
|
+
*/
|
|
21
|
+
name?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An optional function to use to print each log line.
|
|
25
|
+
*
|
|
26
|
+
* If this is specified, `basicLogger` calls it to write each line of output. The
|
|
27
|
+
* argument is a fully formatted log line, not including a linefeed. The function
|
|
28
|
+
* is only called for log levels that are enabled.
|
|
29
|
+
*
|
|
30
|
+
* If not specified, the default is `console.error`.
|
|
31
|
+
*
|
|
32
|
+
* Setting this property to anything other than a function will cause SDK
|
|
33
|
+
* initialization to fail.
|
|
34
|
+
*/
|
|
35
|
+
destination?: (line: string) => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* An optional formatter to use. The formatter should be compatible
|
|
39
|
+
* with browser-style format strings like those used with `util.format`.
|
|
40
|
+
*
|
|
41
|
+
* If not specified, then a default implementation will be used.
|
|
42
|
+
* But using a browser-specific implementation, for instance, would
|
|
43
|
+
* have performance and quality benefits.
|
|
44
|
+
*/
|
|
45
|
+
formatter?: (...args: any[]) => string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FeatBit client logger interface.
|
|
3
|
+
*
|
|
4
|
+
* The {@link IOptions.logger} property accepts any object that conforms to this
|
|
5
|
+
* interface. The SDK only uses four logging levels: `error`, `warn`, `info`, and
|
|
6
|
+
* `debug`. It will call the corresponding method of the `ILogger` either with a
|
|
7
|
+
* single string argument, or with a format string and variable arguments in the
|
|
8
|
+
* format used by Node's `util.format()`.
|
|
9
|
+
*
|
|
10
|
+
* The [Winston](https://github.com/winstonjs/winston) logging package provides a
|
|
11
|
+
* logger that conforms to this interface, so if you have created a logger with
|
|
12
|
+
* Winston, you can simply put it into the {@link IOptions.logger} property.
|
|
13
|
+
*
|
|
14
|
+
* If you do not provide a logger object, the SDK uses the {@link basicLogger}
|
|
15
|
+
* implementation with a minimum level of `info`.
|
|
16
|
+
*/
|
|
17
|
+
export interface ILogger {
|
|
18
|
+
/**
|
|
19
|
+
* The error logger.
|
|
20
|
+
*
|
|
21
|
+
* @param args
|
|
22
|
+
* A sequence of any JavaScript values.
|
|
23
|
+
*/
|
|
24
|
+
error(...args: any[]): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The warning logger.
|
|
28
|
+
*
|
|
29
|
+
* @param args
|
|
30
|
+
* A sequence of any JavaScript values.
|
|
31
|
+
*/
|
|
32
|
+
warn(...args: any[]): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The info logger.
|
|
36
|
+
*
|
|
37
|
+
* @param args
|
|
38
|
+
* A sequence of any JavaScript values.
|
|
39
|
+
*/
|
|
40
|
+
info(...args: any[]): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The debug logger.
|
|
44
|
+
*
|
|
45
|
+
* @param args
|
|
46
|
+
* A sequence of any JavaScript values.
|
|
47
|
+
*/
|
|
48
|
+
debug(...args: any[]): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging levels that can be used with {@link basicLogger}.
|
|
3
|
+
*
|
|
4
|
+
* Set {@link BasicLoggerOptions.level} to one of these values to control what levels
|
|
5
|
+
* of log messages are enabled. Going from lowest importance (and most verbose)
|
|
6
|
+
* to most importance, the levels are `'debug'`, `'info'`, `'warn'`, and `'error'`.
|
|
7
|
+
* You can also specify `'none'` instead to disable all logging.
|
|
8
|
+
*/
|
|
9
|
+
export type ILogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ILogger } from "./ILogger";
|
|
2
|
+
import { TypeValidators } from "../options/Validators";
|
|
3
|
+
|
|
4
|
+
const loggerRequirements = {
|
|
5
|
+
error: TypeValidators.Function,
|
|
6
|
+
warn: TypeValidators.Function,
|
|
7
|
+
info: TypeValidators.Function,
|
|
8
|
+
debug: TypeValidators.Function,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The safeLogger logic exists because we allow the application to pass in a custom logger, but
|
|
13
|
+
* there is no guarantee that the logger works correctly and if it ever throws exceptions there
|
|
14
|
+
* could be serious consequences (e.g. an uncaught exception within an error event handler, due
|
|
15
|
+
* to the SDK trying to log the error, can terminate the application). An exception could result
|
|
16
|
+
* from faulty logic in the logger implementation, or it could be that this is not a logger at
|
|
17
|
+
* all but some other kind of object; the former is handled by a catch block that logs an error
|
|
18
|
+
* message to the SDK's default logger, and we can at least partly guard against the latter by
|
|
19
|
+
* checking for the presence of required methods at configuration time.
|
|
20
|
+
*/
|
|
21
|
+
export default class SafeLogger implements ILogger {
|
|
22
|
+
private logger: ILogger;
|
|
23
|
+
|
|
24
|
+
private fallback: ILogger;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Construct a safe logger with the specified logger.
|
|
28
|
+
* @param logger The logger to use.
|
|
29
|
+
* @param fallback A fallback logger to use in case an issue is encountered using
|
|
30
|
+
* the provided logger.
|
|
31
|
+
*/
|
|
32
|
+
constructor(logger: ILogger, fallback: ILogger) {
|
|
33
|
+
Object.entries(loggerRequirements).forEach(([level, validator]) => {
|
|
34
|
+
if (!validator.is((logger as any)[level])) {
|
|
35
|
+
throw new Error(`Provided logger instance must support logger.${ level }(...) method`);
|
|
36
|
+
// Note that the SDK normally does not throw exceptions to the application, but that rule
|
|
37
|
+
// does not apply to FbClientNode.init() which will throw an exception if the parameters are so
|
|
38
|
+
// invalid that we cannot proceed with creating the client. An invalid logger meets those
|
|
39
|
+
// criteria since the SDK calls the logger during nearly all of its operations.
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.logger = logger;
|
|
43
|
+
this.fallback = fallback;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private log(level: 'error' | 'warn' | 'info' | 'debug', args: any[]) {
|
|
47
|
+
try {
|
|
48
|
+
this.logger[level](...args);
|
|
49
|
+
} catch {
|
|
50
|
+
// If all else fails do not break.
|
|
51
|
+
this.fallback[level](...args);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
error(...args: any[]): void {
|
|
56
|
+
this.log('error', args);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
warn(...args: any[]): void {
|
|
60
|
+
this.log('warn', args);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
info(...args: any[]): void {
|
|
64
|
+
this.log('info', args);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
debug(...args: any[]): void {
|
|
68
|
+
this.log('debug', args);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { TypeValidators } from "../options/Validators";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Attempt to produce a string representation of a value.
|
|
6
|
+
* The format should be roughly comparable to `util.format`
|
|
7
|
+
* aside from object which will be JSON versus the `util.inspect`
|
|
8
|
+
* format.
|
|
9
|
+
* @param val
|
|
10
|
+
* @returns A string representation of the value if possible.
|
|
11
|
+
*/
|
|
12
|
+
function tryStringify(val: any) {
|
|
13
|
+
if (typeof val === 'string') {
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
if (val === undefined) {
|
|
17
|
+
return 'undefined';
|
|
18
|
+
}
|
|
19
|
+
if (val === null) {
|
|
20
|
+
return 'null';
|
|
21
|
+
}
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(val, 'toString')) {
|
|
23
|
+
try {
|
|
24
|
+
return val.toString();
|
|
25
|
+
} catch {
|
|
26
|
+
/* Keep going */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof val === 'bigint') {
|
|
31
|
+
return `${ val }n`;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return JSON.stringify(val);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error instanceof TypeError && error.message.indexOf('circular') >= 0) {
|
|
37
|
+
return '[Circular]';
|
|
38
|
+
}
|
|
39
|
+
return '[Not Stringifiable]';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Attempt to produce a numeric representation.
|
|
45
|
+
* BigInts have an `n` suffix.
|
|
46
|
+
* @param val
|
|
47
|
+
* @returns The numeric representation or 'NaN' if not numeric.
|
|
48
|
+
*/
|
|
49
|
+
function toNumber(val: any): string {
|
|
50
|
+
// Symbol has to be treated special because it will
|
|
51
|
+
// throw an exception if an attempt is made to convert it.
|
|
52
|
+
if (typeof val === 'symbol') {
|
|
53
|
+
return 'NaN';
|
|
54
|
+
}
|
|
55
|
+
if (typeof val === 'bigint') {
|
|
56
|
+
return `${ val }n`;
|
|
57
|
+
}
|
|
58
|
+
return String(Number(val));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Attempt to produce an integer representation.
|
|
63
|
+
* BigInts have an `n` suffix.
|
|
64
|
+
* @param val
|
|
65
|
+
* @returns The integer representation or 'NaN' if not numeric.
|
|
66
|
+
*/
|
|
67
|
+
function toInt(val: any): string {
|
|
68
|
+
if (typeof val === 'symbol') {
|
|
69
|
+
return 'NaN';
|
|
70
|
+
}
|
|
71
|
+
if (typeof val === 'bigint') {
|
|
72
|
+
return `${ val }n`;
|
|
73
|
+
}
|
|
74
|
+
return String(parseInt(val, 10));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Attempt to produce a float representation.
|
|
79
|
+
* BigInts have an `n` suffix.
|
|
80
|
+
* @param val
|
|
81
|
+
* @returns The integer representation or 'NaN' if not numeric.
|
|
82
|
+
*/
|
|
83
|
+
function toFloat(val: any): string {
|
|
84
|
+
if (typeof val === 'symbol') {
|
|
85
|
+
return 'NaN';
|
|
86
|
+
}
|
|
87
|
+
return String(parseFloat(val));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Based on:
|
|
91
|
+
// https://nodejs.org/api/util.html#utilformatformat-args
|
|
92
|
+
// The result will not match browser exactly, but it should get the
|
|
93
|
+
// right information through.
|
|
94
|
+
const escapes: Record<string, (val: any) => string> = {
|
|
95
|
+
s: (val: any) => tryStringify(val),
|
|
96
|
+
d: (val: any) => toNumber(val),
|
|
97
|
+
i: (val: any) => toInt(val),
|
|
98
|
+
f: (val: any) => toFloat(val),
|
|
99
|
+
j: (val: any) => tryStringify(val),
|
|
100
|
+
o: (val: any) => tryStringify(val),
|
|
101
|
+
O: (val: any) => tryStringify(val),
|
|
102
|
+
c: () => '',
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A basic formatted for use where `util.format` is not available.
|
|
107
|
+
* This will not be as performant, but it will produce formatted
|
|
108
|
+
* messages.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*
|
|
112
|
+
* @param args
|
|
113
|
+
* @returns Formatted string.
|
|
114
|
+
*/
|
|
115
|
+
export default function format(...args: any[]): string {
|
|
116
|
+
const formatString = args.shift();
|
|
117
|
+
if (TypeValidators.String.is(formatString)) {
|
|
118
|
+
let out = '';
|
|
119
|
+
let i = 0;
|
|
120
|
+
while (i < formatString.length) {
|
|
121
|
+
const char = formatString.charAt(i);
|
|
122
|
+
if (char === '%') {
|
|
123
|
+
const nextIndex = i + 1;
|
|
124
|
+
if (nextIndex < formatString.length) {
|
|
125
|
+
const nextChar = formatString.charAt(i + 1);
|
|
126
|
+
if (nextChar in escapes && args.length) {
|
|
127
|
+
const value = args.shift();
|
|
128
|
+
// This rule is for math.
|
|
129
|
+
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
130
|
+
out += escapes[nextChar]?.(value);
|
|
131
|
+
} else if (nextChar === '%') {
|
|
132
|
+
out += '%';
|
|
133
|
+
} else {
|
|
134
|
+
out += `%${ nextChar }`;
|
|
135
|
+
}
|
|
136
|
+
i += 2;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
out += char;
|
|
140
|
+
i += 1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// If there are any args left after we exhaust the format string
|
|
144
|
+
// then just stick those on the end.
|
|
145
|
+
if (args.length) {
|
|
146
|
+
if (out.length) {
|
|
147
|
+
out += ' ';
|
|
148
|
+
}
|
|
149
|
+
out += args.map(tryStringify).join(' ');
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
return args.map(tryStringify).join(' ');
|
|
154
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ILogger } from "../logging/ILogger";
|
|
2
|
+
import { IPlatform } from "../platform/IPlatform";
|
|
3
|
+
import { IClientContext } from "./IClientContext";
|
|
4
|
+
import { IUser } from "./IUser";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The client context provides basic configuration and platform support which are required
|
|
8
|
+
* when building SDK components.
|
|
9
|
+
*/
|
|
10
|
+
export default class ClientContext implements IClientContext {
|
|
11
|
+
flushInterval: number;
|
|
12
|
+
maxEventsInQueue: number;
|
|
13
|
+
offline: boolean;
|
|
14
|
+
logger: ILogger;
|
|
15
|
+
eventsUri: string;
|
|
16
|
+
pollingUri: string;
|
|
17
|
+
streamingUri: string;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
public readonly sdkKey: string,
|
|
21
|
+
configuration: {
|
|
22
|
+
logger?: ILogger;
|
|
23
|
+
offline?: boolean;
|
|
24
|
+
flushInterval: number;
|
|
25
|
+
maxEventsInQueue: number;
|
|
26
|
+
streamingUri: string;
|
|
27
|
+
pollingUri: string;
|
|
28
|
+
eventsUri: string;
|
|
29
|
+
},
|
|
30
|
+
public readonly platform: IPlatform,
|
|
31
|
+
) {
|
|
32
|
+
this.logger = configuration.logger!;
|
|
33
|
+
this.offline = configuration.offline!;
|
|
34
|
+
this.flushInterval = configuration.flushInterval;
|
|
35
|
+
this.maxEventsInQueue = configuration.maxEventsInQueue;
|
|
36
|
+
this.streamingUri = configuration.streamingUri;
|
|
37
|
+
this.pollingUri = configuration.pollingUri;
|
|
38
|
+
this.eventsUri = configuration.eventsUri;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ILogger } from "../logging/ILogger";
|
|
2
|
+
import { IPlatform } from "../platform/IPlatform";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Factory methods receive this class as a parameter.
|
|
6
|
+
*
|
|
7
|
+
* Its public properties provide information about the SDK configuration and environment. The SDK
|
|
8
|
+
* may also include non-public properties that are relevant only when creating one of the built-in
|
|
9
|
+
* component types and are not accessible to custom components.
|
|
10
|
+
*/
|
|
11
|
+
export interface IClientContext {
|
|
12
|
+
|
|
13
|
+
logger?: ILogger;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* True if the SDK was configured to be completely offline.
|
|
17
|
+
*/
|
|
18
|
+
offline?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The configured SDK key.
|
|
22
|
+
*/
|
|
23
|
+
sdkKey: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The base URI of the data-sync service
|
|
27
|
+
*/
|
|
28
|
+
streamingUri: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The base URI of the polling service
|
|
32
|
+
*/
|
|
33
|
+
pollingUri: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The base URI of the event service
|
|
37
|
+
*/
|
|
38
|
+
eventsUri: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The interval in between flushes of events queue, in milliseconds.
|
|
42
|
+
*/
|
|
43
|
+
flushInterval: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The max number of events in the events queue.
|
|
47
|
+
*/
|
|
48
|
+
maxEventsInQueue: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Interfaces providing platform specific information and functionality.
|
|
52
|
+
*/
|
|
53
|
+
platform: IPlatform;
|
|
54
|
+
}
|
|
@@ -0,0 +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);
|
|
124
|
+
}
|