@featbit/js-client-sdk 2.0.1 → 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 +162 -150
- 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.1.js +0 -2
- package/umd/featbit-js-client-sdk-2.0.1.js.map +0 -1
- package/umd/featbit-js-client-sdk.js +0 -2
- package/umd/featbit-js-client-sdk.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featbit/js-client-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "https://github.com/featbit/featbit-js-client-sdk",
|
|
5
|
-
"main": "esm/index.js",
|
|
5
|
+
"main": "./dist/esm/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
6
11
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"clean": "gts clean",
|
|
13
|
-
"compile": "tsc",
|
|
14
|
-
"fix": "gts fix"
|
|
12
|
+
"prebuild": "node -p \"'export const version = \\\"' + require('./package.json').version + '\\\"; export const name = \\\"' + require('./package.json').name + '\\\";'\" > src/version.ts",
|
|
13
|
+
"build": "rimraf dist && tsc -p tsconfig.json && webpack --mode production",
|
|
14
|
+
"test": "npx jest --ci",
|
|
15
|
+
"test-coverage": "npx jest --ci --coverage",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
15
17
|
},
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
@@ -19,30 +21,26 @@
|
|
|
19
21
|
},
|
|
20
22
|
"keywords": [
|
|
21
23
|
"featbit",
|
|
24
|
+
"client sdk",
|
|
22
25
|
"feature flags",
|
|
23
26
|
"feature management"
|
|
24
27
|
],
|
|
25
28
|
"author": "featbit.co",
|
|
26
|
-
"license": "
|
|
29
|
+
"license": "MIT",
|
|
27
30
|
"bugs": {
|
|
28
31
|
"url": "https://github.com/featbit/featbit-js-client-sdk/issues"
|
|
29
32
|
},
|
|
30
33
|
"homepage": "https://github.com/featbit/featbit-js-client-sdk#readme",
|
|
31
|
-
"files": [
|
|
32
|
-
"/esm",
|
|
33
|
-
"/umd",
|
|
34
|
-
"/src"
|
|
35
|
-
],
|
|
36
34
|
"devDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
35
|
+
"@types/jest": "^29.5.11",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
38
|
+
"rimraf": "^5.0.5",
|
|
39
39
|
"string-replace-loader": "^3.1.0",
|
|
40
|
-
"ts-
|
|
41
|
-
"
|
|
40
|
+
"ts-jest": "^29.1.1",
|
|
41
|
+
"ts-loader": "^9.5.1",
|
|
42
42
|
"typescript": "^5.2.2",
|
|
43
|
-
"webpack": "^5.
|
|
44
|
-
"webpack-cli": "^
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
43
|
+
"webpack": "^5.91.0",
|
|
44
|
+
"webpack-cli": "^5.1.4"
|
|
47
45
|
}
|
|
48
46
|
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { IOptions } from "./options/IOptions";
|
|
2
|
+
import { ILogger } from "./logging/ILogger";
|
|
3
|
+
import { IValidatedOptions } from "./options/IValidatedOptions";
|
|
4
|
+
import { NumberWithMinimum, TypeValidator, TypeValidators, UserValidator } from "./options/Validators";
|
|
5
|
+
import OptionMessages from "./options/OptionMessages";
|
|
6
|
+
import { IStore } from "./platform/IStore";
|
|
7
|
+
import { IClientContext } from "./options/IClientContext";
|
|
8
|
+
import { IDataSynchronizer } from "./data-sync/IDataSynchronizer";
|
|
9
|
+
import { IDataSourceUpdates } from "./store/IDataSourceUpdates";
|
|
10
|
+
import InMemoryStore from "./store/InMemoryStore";
|
|
11
|
+
import { VoidFunction } from "./utils/VoidFunction";
|
|
12
|
+
import { isNullOrUndefined } from "./utils/isNullOrUndefined";
|
|
13
|
+
import { canonicalizeUri } from "./utils/canonicalizeUri";
|
|
14
|
+
import { IBootstrapProvider } from "./bootstrap/IBootstrapProvider";
|
|
15
|
+
import { NullBootstrapProvider } from "./bootstrap/NullBootstrapProvider";
|
|
16
|
+
import { EmptyString } from "./constants";
|
|
17
|
+
import { DataSyncModeEnum } from "./data-sync/DataSyncMode";
|
|
18
|
+
import { IUser } from "./options/IUser";
|
|
19
|
+
import LocalStorageStore from "./platform/browser/LocalStorageStore";
|
|
20
|
+
import { JsonBootstrapProvider } from "./bootstrap";
|
|
21
|
+
|
|
22
|
+
// Once things are internal to the implementation of the SDK we can depend on
|
|
23
|
+
// types. Calls to the SDK could contain anything without any regard to typing.
|
|
24
|
+
// So, data we take from external sources must be normalized into something
|
|
25
|
+
// that can be trusted.
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* These perform cursory validations. Complex objects are implemented with classes
|
|
29
|
+
* and these should allow for conditional construction.
|
|
30
|
+
*/
|
|
31
|
+
const validations: Record<string, TypeValidator> = {
|
|
32
|
+
startWaitTime: TypeValidators.Number,
|
|
33
|
+
sdkKey: TypeValidators.String,
|
|
34
|
+
pollingUri: TypeValidators.String,
|
|
35
|
+
streamingUri: TypeValidators.String,
|
|
36
|
+
eventsUri: TypeValidators.String,
|
|
37
|
+
webSocketPingInterval: TypeValidators.Number,
|
|
38
|
+
logger: TypeValidators.Object,
|
|
39
|
+
store: TypeValidators.ObjectOrFactory,
|
|
40
|
+
dataSynchronizer: TypeValidators.ObjectOrFactory,
|
|
41
|
+
flushInterval: TypeValidators.Number,
|
|
42
|
+
maxEventsInQueue: TypeValidators.Number,
|
|
43
|
+
pollingInterval: TypeValidators.Number,
|
|
44
|
+
offline: TypeValidators.Boolean,
|
|
45
|
+
dataSyncMode: TypeValidators.String,
|
|
46
|
+
bootstrap: TypeValidators.Bootstrap,
|
|
47
|
+
user: TypeValidators.User
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export const defaultValues: IValidatedOptions = {
|
|
54
|
+
startWaitTime: 5000,
|
|
55
|
+
sdkKey: '',
|
|
56
|
+
pollingUri: '',
|
|
57
|
+
streamingUri: '',
|
|
58
|
+
eventsUri: '',
|
|
59
|
+
dataSyncMode: DataSyncModeEnum.STREAMING,
|
|
60
|
+
sendEvents: true,
|
|
61
|
+
webSocketPingInterval: 18 * 1000,
|
|
62
|
+
flushInterval: 2000,
|
|
63
|
+
maxEventsInQueue: 10000,
|
|
64
|
+
pollingInterval: 30000,
|
|
65
|
+
offline: false,
|
|
66
|
+
store: (options: IOptions) => new LocalStorageStore(options),
|
|
67
|
+
bootstrap: undefined,
|
|
68
|
+
user: undefined,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function validateTypesAndNames(options: IOptions): {
|
|
72
|
+
errors: string[];
|
|
73
|
+
validatedOptions: IValidatedOptions;
|
|
74
|
+
} {
|
|
75
|
+
let errors: string[] = [];
|
|
76
|
+
const validatedOptions: IValidatedOptions = {...defaultValues};
|
|
77
|
+
Object.keys(options).forEach((optionName) => {
|
|
78
|
+
// We need to tell typescript it doesn't actually know what options are.
|
|
79
|
+
// If we don't then it complains we are doing crazy things with it.
|
|
80
|
+
const optionValue = (options as unknown as any)[optionName];
|
|
81
|
+
const validator = validations[optionName];
|
|
82
|
+
if (validator) {
|
|
83
|
+
if (!validator.is(optionValue)) {
|
|
84
|
+
if (validator.getType() === 'boolean') {
|
|
85
|
+
errors.push(OptionMessages.wrongOptionTypeBoolean(optionName, typeof optionValue));
|
|
86
|
+
validatedOptions[optionName] = !!optionValue;
|
|
87
|
+
} else if (
|
|
88
|
+
validator instanceof NumberWithMinimum &&
|
|
89
|
+
TypeValidators.Number.is(optionValue)
|
|
90
|
+
) {
|
|
91
|
+
const {min} = validator as NumberWithMinimum;
|
|
92
|
+
errors.push(OptionMessages.optionBelowMinimum(optionName, optionValue, min));
|
|
93
|
+
validatedOptions[optionName] = min;
|
|
94
|
+
} else if (validator instanceof UserValidator) {
|
|
95
|
+
errors = [...errors, ...validator.messages];
|
|
96
|
+
validatedOptions[optionName] = defaultValues[optionName];
|
|
97
|
+
} else {
|
|
98
|
+
errors.push(
|
|
99
|
+
OptionMessages.wrongOptionType(optionName, validator.getType(), typeof optionValue),
|
|
100
|
+
);
|
|
101
|
+
validatedOptions[optionName] = defaultValues[optionName];
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
validatedOptions[optionName] = optionValue;
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
options.logger?.warn(OptionMessages.unknownOption(optionName));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return {errors, validatedOptions};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function validateEndpoints(options: IOptions, validatedOptions: IValidatedOptions) {
|
|
114
|
+
const {streamingUri, pollingUri, eventsUri} = options;
|
|
115
|
+
const streamingUriMissing = isNullOrUndefined(streamingUri) || streamingUri === EmptyString;
|
|
116
|
+
const pollingUriMissing = isNullOrUndefined(pollingUri) || pollingUri === EmptyString;
|
|
117
|
+
const eventsUriMissing = isNullOrUndefined(eventsUri) || eventsUri === EmptyString;
|
|
118
|
+
|
|
119
|
+
if (!validatedOptions.offline && (eventsUriMissing || (streamingUriMissing && pollingUriMissing))) {
|
|
120
|
+
if (eventsUriMissing) {
|
|
121
|
+
validatedOptions.logger?.error(OptionMessages.partialEndpoint('eventsUri'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (validatedOptions.dataSyncMode === DataSyncModeEnum.STREAMING && streamingUriMissing) {
|
|
125
|
+
validatedOptions.logger?.error(OptionMessages.partialEndpoint('streamingUri'));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (validatedOptions.dataSyncMode === DataSyncModeEnum.POLLING && pollingUriMissing) {
|
|
129
|
+
validatedOptions.logger?.error(OptionMessages.partialEndpoint('pollingUri'));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default class Configuration {
|
|
135
|
+
public readonly startWaitTime: number;
|
|
136
|
+
|
|
137
|
+
public readonly sdkKey: string;
|
|
138
|
+
|
|
139
|
+
public readonly streamingUri: string;
|
|
140
|
+
|
|
141
|
+
public readonly pollingUri: string;
|
|
142
|
+
|
|
143
|
+
public readonly eventsUri: string;
|
|
144
|
+
|
|
145
|
+
public readonly webSocketPingInterval: number;
|
|
146
|
+
|
|
147
|
+
public readonly logger?: ILogger;
|
|
148
|
+
|
|
149
|
+
public readonly flushInterval: number;
|
|
150
|
+
|
|
151
|
+
public readonly maxEventsInQueue: number;
|
|
152
|
+
|
|
153
|
+
public readonly pollingInterval: number;
|
|
154
|
+
|
|
155
|
+
public readonly offline: boolean;
|
|
156
|
+
|
|
157
|
+
public readonly dataSyncMode: DataSyncModeEnum;
|
|
158
|
+
|
|
159
|
+
public readonly bootstrapProvider: IBootstrapProvider = new NullBootstrapProvider();
|
|
160
|
+
|
|
161
|
+
public readonly user: IUser;
|
|
162
|
+
|
|
163
|
+
public readonly storeFactory: (clientContext: IClientContext) => IStore;
|
|
164
|
+
|
|
165
|
+
public readonly dataSynchronizerFactory?: (
|
|
166
|
+
clientContext: IClientContext,
|
|
167
|
+
store: IStore,
|
|
168
|
+
dataSourceUpdates: IDataSourceUpdates,
|
|
169
|
+
initSuccessHandler: VoidFunction,
|
|
170
|
+
errorHandler?: (e: Error) => void,
|
|
171
|
+
) => IDataSynchronizer;
|
|
172
|
+
|
|
173
|
+
constructor(options: IOptions = {}) {
|
|
174
|
+
// The default will handle undefined, but not null.
|
|
175
|
+
// Because we can be called from JS we need to be extra defensive.
|
|
176
|
+
options = options || {};
|
|
177
|
+
// If there isn't a valid logger from the platform, then logs would go nowhere.
|
|
178
|
+
this.logger = options.logger;
|
|
179
|
+
|
|
180
|
+
const {errors, validatedOptions} = validateTypesAndNames(options);
|
|
181
|
+
errors.forEach((error) => {
|
|
182
|
+
this.logger?.warn(error);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
this.user = options.user!;
|
|
186
|
+
|
|
187
|
+
validateEndpoints(options, validatedOptions);
|
|
188
|
+
this.streamingUri = `${ canonicalizeUri(validatedOptions.streamingUri) }/streaming`;
|
|
189
|
+
this.pollingUri = `${ canonicalizeUri(validatedOptions.pollingUri) }/api/public/sdk/client/latest-all`;
|
|
190
|
+
this.eventsUri = `${ canonicalizeUri(validatedOptions.eventsUri) }/api/public/insight/track`;
|
|
191
|
+
|
|
192
|
+
this.startWaitTime = validatedOptions.startWaitTime;
|
|
193
|
+
|
|
194
|
+
this.sdkKey = validatedOptions.sdkKey;
|
|
195
|
+
this.webSocketPingInterval = validatedOptions.webSocketPingInterval!;
|
|
196
|
+
|
|
197
|
+
this.flushInterval = validatedOptions.flushInterval;
|
|
198
|
+
this.maxEventsInQueue = validatedOptions.maxEventsInQueue;
|
|
199
|
+
this.pollingInterval = validatedOptions.pollingInterval;
|
|
200
|
+
|
|
201
|
+
this.offline = validatedOptions.offline;
|
|
202
|
+
if (validatedOptions.bootstrap && validatedOptions.bootstrap.length > 0) {
|
|
203
|
+
try {
|
|
204
|
+
this.bootstrapProvider = new JsonBootstrapProvider(validatedOptions.bootstrap);
|
|
205
|
+
} catch (_) {
|
|
206
|
+
this.logger?.error('Failed to parse bootstrap JSON, use NullBootstrapProvider.');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (this.offline) {
|
|
211
|
+
this.logger?.info('Offline mode enabled. No data synchronization with the FeatBit server will occur.');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.dataSyncMode = validatedOptions.dataSyncMode;
|
|
215
|
+
|
|
216
|
+
if (TypeValidators.Function.is(validatedOptions.dataSynchronizer)) {
|
|
217
|
+
// @ts-ignore
|
|
218
|
+
this.dataSynchronizerFactory = validatedOptions.dataSynchronizer;
|
|
219
|
+
} else {
|
|
220
|
+
// The processor is already created, just have the method return it.
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
this.dataSynchronizerFactory = () => validatedOptions.dataSynchronizer;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (TypeValidators.Function.is(validatedOptions.store)) {
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
this.storeFactory = validatedOptions.store;
|
|
228
|
+
} else {
|
|
229
|
+
// The store is already created, just have the method return it.
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
this.storeFactory = () => validatedOptions.store;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
package/src/Context.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IUser } from "./options/IUser";
|
|
2
|
+
|
|
3
|
+
export default class Context {
|
|
4
|
+
private _user?: IUser;
|
|
5
|
+
/**
|
|
6
|
+
* Is this a valid context. If a valid context cannot be created, then this flag will be true.
|
|
7
|
+
* The validity of a context should be tested before it is used.
|
|
8
|
+
*/
|
|
9
|
+
public readonly valid: boolean;
|
|
10
|
+
|
|
11
|
+
public readonly message?: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Contexts should be created using the static factory method {@link Context.fromUser}.
|
|
15
|
+
*
|
|
16
|
+
* The factory methods are static functions within the class because they access private
|
|
17
|
+
* implementation details, so they cannot be free functions.
|
|
18
|
+
*/
|
|
19
|
+
private constructor(valid: boolean, message?: string) {
|
|
20
|
+
this.valid = valid;
|
|
21
|
+
this.message = message;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static fromUser(user: IUser): Context {
|
|
25
|
+
if (!user) {
|
|
26
|
+
return Context.contextForError('No user specified');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {keyId, name} = user;
|
|
30
|
+
|
|
31
|
+
if (keyId === undefined || keyId === null || keyId.trim() === '') {
|
|
32
|
+
return Context.contextForError('key is mandatory');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const context = new Context(true);
|
|
36
|
+
context._user = user;
|
|
37
|
+
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get user(): IUser {
|
|
42
|
+
return this._user!;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get keyId(): string {
|
|
46
|
+
return this._user!.keyId;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
value(property: string): any {
|
|
50
|
+
if (property === 'keyId') {
|
|
51
|
+
return this._user?.keyId;
|
|
52
|
+
} else if (property === 'name') {
|
|
53
|
+
return this._user?.name;
|
|
54
|
+
} else {
|
|
55
|
+
return this._user?.customizedProperties?.find(x => x.name === property)?.value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static contextForError(message: string) {
|
|
60
|
+
return new Context(false, message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { IFbClient } from "./IFbClient";
|
|
2
|
+
import { IOptions } from "./options/IOptions";
|
|
3
|
+
import FbClient from "./platform/browser/FbClient";
|
|
4
|
+
import { IDataSynchronizer } from "./data-sync/IDataSynchronizer";
|
|
5
|
+
import { IClientContext } from "./options/IClientContext";
|
|
6
|
+
import { IDataSourceUpdates } from "./store/IDataSourceUpdates";
|
|
7
|
+
import { VoidFunction } from "./utils/VoidFunction";
|
|
8
|
+
import { ILogger } from "./logging/ILogger";
|
|
9
|
+
import { DataSyncModeEnum } from "./data-sync/DataSyncMode";
|
|
10
|
+
import { IUser } from "./options/IUser";
|
|
11
|
+
import { IFlagBase } from "./evaluation";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of the FeatBit client.
|
|
15
|
+
*
|
|
16
|
+
* Applications should instantiate a single instance for the lifetime of the application.
|
|
17
|
+
* The client will begin attempting to connect to FeatBit as soon as it is created. To
|
|
18
|
+
* determine when it is ready to use, call {@link IFbClient.waitForInitialization}, or register an
|
|
19
|
+
* event listener for the `"ready"` event using {@link IFbClient.on}.
|
|
20
|
+
*
|
|
21
|
+
* **Important:** Do **not** try to instantiate `FbClient` with its constructor
|
|
22
|
+
* (`new FbClientNode()`); the SDK does not currently support
|
|
23
|
+
* this.
|
|
24
|
+
*
|
|
25
|
+
* @return
|
|
26
|
+
* The new {@link IFbClient} instance.
|
|
27
|
+
*/
|
|
28
|
+
export class FbClientBuilder {
|
|
29
|
+
private _options: IOptions;
|
|
30
|
+
|
|
31
|
+
constructor(options?: IOptions) {
|
|
32
|
+
this._options = options ?? {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new instance of the FeatBit client.
|
|
37
|
+
*/
|
|
38
|
+
build(): IFbClient {
|
|
39
|
+
return new FbClient(this._options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Refer to {@link IOptions.startWaitTime}.
|
|
44
|
+
*/
|
|
45
|
+
startWaitTime(startWaitTime: number): FbClientBuilder {
|
|
46
|
+
this._options.startWaitTime = startWaitTime;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Refer to {@link IOptions.sdkKey}.
|
|
52
|
+
*/
|
|
53
|
+
sdkKey(sdkKey: string): FbClientBuilder {
|
|
54
|
+
this._options.sdkKey = sdkKey;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Refer to {@link IOptions.user}.
|
|
60
|
+
*/
|
|
61
|
+
user(user: IUser): FbClientBuilder {
|
|
62
|
+
this._options.user = user;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Refer to {@link IOptions.streamingUri}.
|
|
68
|
+
*/
|
|
69
|
+
streamingUri(streamingUri: string): FbClientBuilder {
|
|
70
|
+
this._options.streamingUri = streamingUri;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Refer to {@link IOptions.pollingUri}.
|
|
76
|
+
*/
|
|
77
|
+
pollingUri(pollingUri: string): FbClientBuilder {
|
|
78
|
+
this._options.pollingUri = pollingUri;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Refer to {@link IOptions.eventsUri}.
|
|
84
|
+
*/
|
|
85
|
+
eventsUri(eventsUri: string): FbClientBuilder {
|
|
86
|
+
this._options.eventsUri = eventsUri;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Refer to {@link IOptions.dataSyncMode}.
|
|
92
|
+
*/
|
|
93
|
+
dataSyncMode(mode: DataSyncModeEnum): FbClientBuilder {
|
|
94
|
+
this._options.dataSyncMode = mode;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Refer to {@link IOptions.pollingInterval}.
|
|
100
|
+
*/
|
|
101
|
+
pollingInterval(pollingInterval: number): FbClientBuilder {
|
|
102
|
+
this._options.pollingInterval = pollingInterval;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Refer to {@link IOptions.flushInterval}.
|
|
108
|
+
*/
|
|
109
|
+
flushInterval(flushInterval: number): FbClientBuilder {
|
|
110
|
+
this._options.flushInterval = flushInterval;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Refer to {@link IOptions.maxEventsInQueue}.
|
|
116
|
+
*/
|
|
117
|
+
maxEventsInQueue(maxEventsInQueue: number): FbClientBuilder {
|
|
118
|
+
this._options.maxEventsInQueue = maxEventsInQueue;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Refer to {@link IOptions.logger}.
|
|
124
|
+
*/
|
|
125
|
+
logger(logger: ILogger): FbClientBuilder {
|
|
126
|
+
this._options.logger = logger;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Refer to {@link IOptions.offline}.
|
|
132
|
+
*/
|
|
133
|
+
offline(offline: boolean): FbClientBuilder {
|
|
134
|
+
this._options.offline = offline;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Use the JsonBootstrapProvider.
|
|
140
|
+
*/
|
|
141
|
+
bootstrap(flags: IFlagBase[]): FbClientBuilder {
|
|
142
|
+
this._options.bootstrap = flags;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Refer to {@link IOptions.dataSynchronizer}.
|
|
148
|
+
*/
|
|
149
|
+
dataSynchronizer(
|
|
150
|
+
dataSynchronizer: IDataSynchronizer |
|
|
151
|
+
((
|
|
152
|
+
clientContext: IClientContext,
|
|
153
|
+
dataSourceUpdates: IDataSourceUpdates,
|
|
154
|
+
initSuccessHandler: VoidFunction,
|
|
155
|
+
errorHandler?: (e: Error) => void,
|
|
156
|
+
) => IDataSynchronizer)
|
|
157
|
+
): FbClientBuilder {
|
|
158
|
+
this._options.dataSynchronizer = dataSynchronizer;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
}
|