@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ILogger } from "../logging/ILogger";
|
|
2
|
+
import { IStore } from "../platform/IStore";
|
|
3
|
+
import { IOptions } from "./IOptions";
|
|
4
|
+
import { IDataSynchronizer } from "../data-sync/IDataSynchronizer";
|
|
5
|
+
import { DataSyncModeEnum } from "../data-sync/DataSyncMode";
|
|
6
|
+
import { IUser } from "./IUser";
|
|
7
|
+
import { IBootstrapProvider } from "../bootstrap";
|
|
8
|
+
import { IFlagBase } from "../evaluation";
|
|
9
|
+
|
|
10
|
+
export interface IValidatedOptions {
|
|
11
|
+
startWaitTime: number;
|
|
12
|
+
sdkKey: string;
|
|
13
|
+
pollingUri: string;
|
|
14
|
+
streamingUri: string;
|
|
15
|
+
eventsUri: string;
|
|
16
|
+
dataSyncMode: DataSyncModeEnum;
|
|
17
|
+
webSocketPingInterval?: number;
|
|
18
|
+
flushInterval: number;
|
|
19
|
+
maxEventsInQueue: number;
|
|
20
|
+
pollingInterval: number;
|
|
21
|
+
offline: boolean;
|
|
22
|
+
store: IStore | ((options: IOptions) => IStore);
|
|
23
|
+
dataSynchronizer?: IDataSynchronizer;
|
|
24
|
+
logger?: ILogger;
|
|
25
|
+
user?: IUser;
|
|
26
|
+
bootstrap?: IFlagBase[];
|
|
27
|
+
|
|
28
|
+
// Allow indexing this by a string for the validation step.
|
|
29
|
+
[index: string]: any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messages for issues which can be encountered from processing the configuration options.
|
|
3
|
+
*/
|
|
4
|
+
export default class OptionMessages {
|
|
5
|
+
static optionBelowMinimum(name: string, value: number, min: number): string {
|
|
6
|
+
return `Config option "${ name }" had invalid value of ${ value }, using minimum of ${ min } instead`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static unknownOption(name: string): string {
|
|
10
|
+
return `Ignoring unknown config option "${ name }"`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static wrongOptionType(name: string, expectedType: string, actualType: string): string {
|
|
14
|
+
return `Config option "${ name }" should be of type ${ expectedType }, got ${ actualType }, using default value`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static wrongOptionTypeBoolean(name: string, actualType: string): string {
|
|
18
|
+
return `Config option "${ name }" should be a boolean, got ${ actualType }, converting to boolean`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static partialEndpoint(name: string): string {
|
|
22
|
+
return `You have set custom uris without specifying the ${ name } URI; connections may not work properly`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static mandatory(name: string): string {
|
|
26
|
+
return `${ name } is mandatory`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static invalidOptionValue(name: string): string {
|
|
30
|
+
return `Invalid option value: ${ name }`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static missingKeyInBootstrapValue(key: string): string {
|
|
34
|
+
return `Missing key "${ key }" in bootstrap value`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IUser } from "./IUser";
|
|
2
|
+
import {IContextProperty} from "../IContextProperty";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates an instance of the FeatBit user.
|
|
6
|
+
*
|
|
7
|
+
* @return
|
|
8
|
+
* The new {@link IUser} instance.
|
|
9
|
+
*/
|
|
10
|
+
export class UserBuilder {
|
|
11
|
+
private _keyId: string = '';
|
|
12
|
+
private _name: string = '';
|
|
13
|
+
private _custom: IContextProperty[] = [];
|
|
14
|
+
|
|
15
|
+
constructor(keyId: string) {
|
|
16
|
+
this._keyId = keyId;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
name(name: string): UserBuilder {
|
|
20
|
+
this._name = name;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
custom(propertyName: string, value: string): UserBuilder {
|
|
25
|
+
this._custom?.push({ name: propertyName, value: value });
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
build(): IUser {
|
|
30
|
+
return {
|
|
31
|
+
name: this._name,
|
|
32
|
+
keyId: this._keyId,
|
|
33
|
+
customizedProperties: this._custom
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
/* eslint-disable max-classes-per-file */
|
|
3
|
+
|
|
4
|
+
// The classes here are static, but needs to be instantiated to
|
|
5
|
+
// support the generic functionality. Which is why we do not care about using
|
|
6
|
+
// `this`
|
|
7
|
+
|
|
8
|
+
// These validators are also of trivial complexity, so we are allowing more than
|
|
9
|
+
// one per file.
|
|
10
|
+
|
|
11
|
+
import OptionMessages from "./OptionMessages";
|
|
12
|
+
import { IFlagBase } from "../evaluation";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Interface for type validation.
|
|
16
|
+
*/
|
|
17
|
+
export interface TypeValidator {
|
|
18
|
+
// holding validation error messages
|
|
19
|
+
messages?: string[];
|
|
20
|
+
|
|
21
|
+
is(u: unknown): boolean;
|
|
22
|
+
|
|
23
|
+
getType(): string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Validate a factory or instance.
|
|
28
|
+
*/
|
|
29
|
+
export class FactoryOrInstance implements TypeValidator {
|
|
30
|
+
is(factoryOrInstance: unknown) {
|
|
31
|
+
if (Array.isArray(factoryOrInstance)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const anyFactory = factoryOrInstance as any;
|
|
35
|
+
const typeOfFactory = typeof anyFactory;
|
|
36
|
+
return typeOfFactory === 'function' || typeOfFactory === 'object';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getType(): string {
|
|
40
|
+
return 'factory method or object';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Validate a basic type.
|
|
46
|
+
*/
|
|
47
|
+
export class Type<T> implements TypeValidator {
|
|
48
|
+
private typeName: string;
|
|
49
|
+
|
|
50
|
+
protected typeOf: string;
|
|
51
|
+
|
|
52
|
+
constructor(typeName: string, example: T) {
|
|
53
|
+
this.typeName = typeName;
|
|
54
|
+
this.typeOf = typeof example;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
is(u: unknown): u is T {
|
|
58
|
+
if (Array.isArray(u)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return typeof u === this.typeOf;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getType(): string {
|
|
65
|
+
return this.typeName;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Validate an array of the specified type.
|
|
71
|
+
*
|
|
72
|
+
* This does not validate instances of types. All class instances
|
|
73
|
+
* of classes will simply objects.
|
|
74
|
+
*/
|
|
75
|
+
export class TypeArray<T> implements TypeValidator {
|
|
76
|
+
private typeName: string;
|
|
77
|
+
|
|
78
|
+
protected typeOf: string;
|
|
79
|
+
|
|
80
|
+
constructor(typeName: string, example: T) {
|
|
81
|
+
this.typeName = typeName;
|
|
82
|
+
this.typeOf = typeof example;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
is(u: unknown): u is T {
|
|
86
|
+
if (Array.isArray(u)) {
|
|
87
|
+
if (u.length > 0) {
|
|
88
|
+
return u.every((val) => typeof val === this.typeOf);
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getType(): string {
|
|
96
|
+
return this.typeName;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Validate a value is a number and is greater or eval than a minimum.
|
|
102
|
+
*/
|
|
103
|
+
export class NumberWithMinimum extends Type<number> {
|
|
104
|
+
readonly min: number;
|
|
105
|
+
|
|
106
|
+
constructor(min: number) {
|
|
107
|
+
super(`number with minimum value of ${ min }`, 0);
|
|
108
|
+
this.min = min;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
override is(u: unknown): u is number {
|
|
112
|
+
return typeof u === this.typeOf && (u as number) >= this.min;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Validate a value is a string and it matches the given expression.
|
|
118
|
+
*/
|
|
119
|
+
export class StringMatchingRegex extends Type<string> {
|
|
120
|
+
readonly expression: RegExp;
|
|
121
|
+
|
|
122
|
+
constructor(expression: RegExp) {
|
|
123
|
+
super(`string matching ${ expression }`, '');
|
|
124
|
+
this.expression = expression;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
override is(u: unknown): u is string {
|
|
128
|
+
return !!(u as string).match(this.expression);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Validate a value is a function.
|
|
134
|
+
*/
|
|
135
|
+
export class Function implements TypeValidator {
|
|
136
|
+
is(u: unknown): u is (...args: any[]) => void {
|
|
137
|
+
// We cannot inspect the parameters and there isn't really
|
|
138
|
+
// a generic function type we can instantiate.
|
|
139
|
+
// So the type guard is here just to make TS comfortable
|
|
140
|
+
// calling something after using this guard.
|
|
141
|
+
return typeof u === 'function';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getType(): string {
|
|
145
|
+
return 'function';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class NullableBoolean implements TypeValidator {
|
|
150
|
+
is(u: unknown): boolean {
|
|
151
|
+
return typeof u === 'boolean' || typeof u === 'undefined' || u === null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getType(): string {
|
|
155
|
+
return 'boolean | undefined | null';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export class BootstrapValidator implements TypeValidator {
|
|
160
|
+
messages: string[] = [];
|
|
161
|
+
|
|
162
|
+
is(u: unknown): boolean {
|
|
163
|
+
if (typeof u !== 'object' || u === null) {
|
|
164
|
+
this.messages.push(OptionMessages.invalidOptionValue('bootstrap'));
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const bootstrap = u as IFlagBase[];
|
|
170
|
+
for (let flag of bootstrap) {
|
|
171
|
+
const hasMandatoryKeys = ['id', 'variation'].every((key) => Object.keys(flag).includes(key));
|
|
172
|
+
const keys = Object.keys(flag);
|
|
173
|
+
|
|
174
|
+
if (keys.includes('id')) {
|
|
175
|
+
this.messages.push(OptionMessages.missingKeyInBootstrapValue('id'));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (keys.includes('variation')) {
|
|
179
|
+
this.messages.push(OptionMessages.missingKeyInBootstrapValue('variation'));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (this.messages.length > 0) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (_) {
|
|
187
|
+
this.messages.push(OptionMessages.wrongOptionType('bootstrap', this.getType(), typeof u));
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
getType(): string {
|
|
195
|
+
return 'IFlagBase[]';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export class UserValidator implements TypeValidator {
|
|
200
|
+
messages: string[] = [];
|
|
201
|
+
|
|
202
|
+
is(u: unknown): boolean {
|
|
203
|
+
if (typeof u !== 'object' || u === null) {
|
|
204
|
+
this.messages.push(OptionMessages.mandatory('user'));
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const user = u as any;
|
|
209
|
+
|
|
210
|
+
if (typeof user.keyId !== 'string' || user.keyId.trim() === '') {
|
|
211
|
+
this.messages.push(OptionMessages.mandatory('user.keyId'));
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (typeof user.name !== 'string' || user.name.trim() === '') {
|
|
216
|
+
this.messages.push(OptionMessages.mandatory('user.name'));
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
getType(): string {
|
|
224
|
+
return 'user';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Our reference SDK, Go, parses date/time strings with the time.RFC3339Nano format.
|
|
229
|
+
// This regex should match strings that are valid in that format, and no others.
|
|
230
|
+
// Acceptable:
|
|
231
|
+
// 2019-10-31T23:59:59Z, 2019-10-31T23:59:59.100Z,
|
|
232
|
+
// 2019-10-31T23:59:59-07, 2019-10-31T23:59:59-07:00, etc.
|
|
233
|
+
// Unacceptable: no "T", no time zone designation
|
|
234
|
+
const DATE_REGEX = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d*)?(Z|[-+]\d\d(:\d\d)?)/;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Validate a value is a date. Values which are numbers are treated as dates and any string
|
|
238
|
+
* which if compliant with `time.RFC3339Nano` is a date.
|
|
239
|
+
*/
|
|
240
|
+
export class DateValidator implements TypeValidator {
|
|
241
|
+
is(u: unknown): boolean {
|
|
242
|
+
return typeof u === 'number' || (typeof u === 'string' && DATE_REGEX.test(u));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
getType(): string {
|
|
246
|
+
return 'date';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Validates that a string is a valid kind.
|
|
252
|
+
*/
|
|
253
|
+
export class KindValidator extends StringMatchingRegex {
|
|
254
|
+
constructor() {
|
|
255
|
+
super(/^(\w|\.|-)+$/);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
override is(u: unknown): u is string {
|
|
259
|
+
return super.is(u) && u !== 'kind';
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A set of standard type validators.
|
|
265
|
+
*/
|
|
266
|
+
export class TypeValidators {
|
|
267
|
+
static readonly String = new Type<string>('string', '');
|
|
268
|
+
|
|
269
|
+
static readonly Number = new Type<number>('number', 0);
|
|
270
|
+
|
|
271
|
+
static readonly ObjectOrFactory = new FactoryOrInstance();
|
|
272
|
+
|
|
273
|
+
static readonly Object = new Type<object>('object', {});
|
|
274
|
+
|
|
275
|
+
static readonly StringArray = new TypeArray<string>('string[]', '');
|
|
276
|
+
|
|
277
|
+
static readonly Boolean = new Type<boolean>('boolean', true);
|
|
278
|
+
|
|
279
|
+
static readonly User = new Type<object>('object', {});
|
|
280
|
+
|
|
281
|
+
static readonly Bootstrap = new Type<object>('object', {});
|
|
282
|
+
|
|
283
|
+
static readonly Function = new Function();
|
|
284
|
+
|
|
285
|
+
static createTypeArray<T>(typeName: string, example: T) {
|
|
286
|
+
return new TypeArray<T>(typeName, example);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static numberWithMin(min: number): NumberWithMinimum {
|
|
290
|
+
return new NumberWithMinimum(min);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
static stringMatchingRegex(expression: RegExp): StringMatchingRegex {
|
|
294
|
+
return new StringMatchingRegex(expression);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static readonly Date = new DateValidator();
|
|
298
|
+
|
|
299
|
+
static readonly Kind = new KindValidator();
|
|
300
|
+
static readonly NullableBoolean = new NullableBoolean();
|
|
301
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information about the platform of the SDK and the environment it is executing.
|
|
3
|
+
*/
|
|
4
|
+
export interface IPlatformData {
|
|
5
|
+
/**
|
|
6
|
+
* Information about the OS on which the SDK is running. Should be populated
|
|
7
|
+
* when available. Not all platforms will make this data accessible.
|
|
8
|
+
*/
|
|
9
|
+
os?: {
|
|
10
|
+
/**
|
|
11
|
+
* The architecture. Ideally at runtime, but may be build time if that is
|
|
12
|
+
* a constraint.
|
|
13
|
+
*/
|
|
14
|
+
arch?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the OS. "MacOS", "Windows", or "Linux". If not one of those,
|
|
17
|
+
* then use the value provided by the OS.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
|
|
21
|
+
/** The version of the OS. */
|
|
22
|
+
version?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The name of the platform the SDK is running on. For instance 'Node'.
|
|
27
|
+
*/
|
|
28
|
+
name?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Any additional attributes associated with the platform.
|
|
32
|
+
*/
|
|
33
|
+
additional?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ISdkData {
|
|
37
|
+
/**
|
|
38
|
+
* The name of the SDK. e.g. "browser-server-sdk"
|
|
39
|
+
*/
|
|
40
|
+
name?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The version of the SDK.
|
|
44
|
+
*/
|
|
45
|
+
version?: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* If this is a top-level (not a wrapper) SDK this will be used to create the user agent string.
|
|
49
|
+
* It will take the form 'userAgentBase/version`.
|
|
50
|
+
*/
|
|
51
|
+
userAgentBase?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Name of the wrapper SDK if present.
|
|
55
|
+
*/
|
|
56
|
+
wrapperName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Version of the wrapper if present.
|
|
59
|
+
*/
|
|
60
|
+
wrapperVersion?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Interface for getting information about the SDK or the environment it is
|
|
65
|
+
* executing in.
|
|
66
|
+
*/
|
|
67
|
+
export interface IInfo {
|
|
68
|
+
/**
|
|
69
|
+
* Get the app type
|
|
70
|
+
*/
|
|
71
|
+
get appType(): string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get information about the platform.
|
|
75
|
+
*/
|
|
76
|
+
platformData(): IPlatformData;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get information about the SDK implementation.
|
|
80
|
+
*/
|
|
81
|
+
sdkData(): ISdkData;
|
|
82
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IRequests } from "./requests";
|
|
2
|
+
import { IInfo } from "./IInfo";
|
|
3
|
+
import { IWebSocketWithEvents } from "./IWebSocket";
|
|
4
|
+
|
|
5
|
+
export interface IPlatform {
|
|
6
|
+
/**
|
|
7
|
+
* The interface for getting information about the platform and the execution
|
|
8
|
+
* environment.
|
|
9
|
+
*/
|
|
10
|
+
info: IInfo;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The interface for performing http/https requests.
|
|
14
|
+
*/
|
|
15
|
+
requests: IRequests;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The interface for performing websocket connections.
|
|
19
|
+
*/
|
|
20
|
+
webSocket: IWebSocketWithEvents;
|
|
21
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { IDataKind } from "../IDataKind";
|
|
2
|
+
import { IKeyedStoreItem, IStoreDataStorage, IStoreItem, IStoreKindData } from "../store/store";
|
|
3
|
+
import { IUser } from "../options/IUser";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface for a feature store component.
|
|
7
|
+
*
|
|
8
|
+
* The feature store is what the client uses to store feature flag data that has been received
|
|
9
|
+
* from FeatBit. By default, it uses an in-memory implementation; database integrations are
|
|
10
|
+
* also available. Read the [SDK features guide](xxx).
|
|
11
|
+
* You will not need to use this interface unless you are writing your own implementation.
|
|
12
|
+
*
|
|
13
|
+
* Feature store methods can and should call their callbacks directly whenever possible, rather
|
|
14
|
+
* than deferring them with setImmediate() or process.nextTick(). This means that if for any
|
|
15
|
+
* reason you are updating or querying a feature store directly in your application code (which
|
|
16
|
+
* is not part of normal use of the SDK) you should be aware that the callback may be executed
|
|
17
|
+
* immediately.
|
|
18
|
+
*/
|
|
19
|
+
export interface IStore {
|
|
20
|
+
/**
|
|
21
|
+
* Set the current user of the store.
|
|
22
|
+
*
|
|
23
|
+
* @param user
|
|
24
|
+
* The current user. The actual type of this parameter is
|
|
25
|
+
* {@link IUser}.
|
|
26
|
+
*/
|
|
27
|
+
identify(user: IUser): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the current user of the store.
|
|
31
|
+
*/
|
|
32
|
+
user: IUser;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get an entity from the store.
|
|
36
|
+
*
|
|
37
|
+
* The store should treat any entity with the property `deleted: true` as "not found".
|
|
38
|
+
*
|
|
39
|
+
* @param kind
|
|
40
|
+
* The type of data to be accessed. The store should not make any assumptions about the format
|
|
41
|
+
* of the data, but just return a JSON object. The actual type of this parameter is
|
|
42
|
+
* {@link DataKind}.
|
|
43
|
+
*
|
|
44
|
+
* @param key
|
|
45
|
+
* The unique key of the entity within the specified collection.
|
|
46
|
+
*/
|
|
47
|
+
get(kind: IDataKind, key: string): IStoreItem | null
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get all entities from a collection.
|
|
51
|
+
*
|
|
52
|
+
* The store should filter out any entities with the property `deleted: true`.
|
|
53
|
+
*
|
|
54
|
+
* @param kind
|
|
55
|
+
* The type of data to be accessed. The store should not make any assumptions about the format
|
|
56
|
+
* of the data, but just return an object in which each key is the `key` property of an entity
|
|
57
|
+
* and the value is the entity. The actual type of this parameter is
|
|
58
|
+
* {@link IDataKind}.
|
|
59
|
+
*/
|
|
60
|
+
all(kind: IDataKind): [IStoreKindData, number];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the store, overwriting any existing data.
|
|
64
|
+
*
|
|
65
|
+
* @param allData
|
|
66
|
+
* An object in which each key is the "namespace" of a collection (e.g. `"features"`) and
|
|
67
|
+
* the value is an object that maps keys to entities. The actual type of this parameter is
|
|
68
|
+
* `interfaces.FullDataSet<VersionedData>`.
|
|
69
|
+
*
|
|
70
|
+
* @param callback
|
|
71
|
+
* Will be called when the store has been initialized.
|
|
72
|
+
*/
|
|
73
|
+
init(allData: IStoreDataStorage, callback: () => void): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add an entity or update an existing entity.
|
|
77
|
+
*
|
|
78
|
+
* @param kind
|
|
79
|
+
* The type of data to be accessed. The actual type of this parameter is
|
|
80
|
+
* {@link IDataKind}.
|
|
81
|
+
*
|
|
82
|
+
* @param data
|
|
83
|
+
* The contents of the entity, as an object that can be converted to JSON. The store
|
|
84
|
+
* should check the `version` property of this object, and should *not* overwrite any
|
|
85
|
+
* existing data if the existing `version` is greater than or equal to that value.
|
|
86
|
+
* The actual type of this parameter is {@link IKeyedStoreItem}.
|
|
87
|
+
*
|
|
88
|
+
* @param callback
|
|
89
|
+
* Will be called after the upsert operation is complete.
|
|
90
|
+
*/
|
|
91
|
+
upsert(kind: IDataKind, data: IKeyedStoreItem, callback: () => void): void;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Tests whether the store is initialized.
|
|
95
|
+
*
|
|
96
|
+
* "Initialized" means that the store has been populated with data, either by the client
|
|
97
|
+
* having called `init()` within this process, or by another process (if this is a shared
|
|
98
|
+
* database).
|
|
99
|
+
*
|
|
100
|
+
* @param callback
|
|
101
|
+
* Will be called back with the boolean result.
|
|
102
|
+
*/
|
|
103
|
+
initialized(): boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Releases any resources being used by the feature store.
|
|
107
|
+
*/
|
|
108
|
+
close(): void;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get a description of the store.
|
|
112
|
+
*/
|
|
113
|
+
getDescription?(): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The current version of the store.
|
|
117
|
+
*/
|
|
118
|
+
version: number;
|
|
119
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IEventEmitter } from "../utils/IEventEmitter";
|
|
2
|
+
import { ILogger } from "../logging/ILogger";
|
|
3
|
+
import { IUser } from "../options/IUser";
|
|
4
|
+
|
|
5
|
+
export interface IWebSocketConfig {
|
|
6
|
+
sdkKey: string;
|
|
7
|
+
streamingUri: string;
|
|
8
|
+
pingInterval: number;
|
|
9
|
+
user: IUser;
|
|
10
|
+
logger: ILogger;
|
|
11
|
+
getStoreTimestamp: () => number,
|
|
12
|
+
emitter?: IEventEmitter;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IWebSocket {
|
|
16
|
+
connect: () => void;
|
|
17
|
+
close: () => void;
|
|
18
|
+
config: (param: IWebSocketConfig) => void;
|
|
19
|
+
identify: (user: IUser) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IWebSocketWithEvents extends IWebSocket, IEventEmitter {
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IInfo, IPlatformData, ISdkData } from "../IInfo";
|
|
2
|
+
import { name, version } from '../../version';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default class BrowserInfo implements IInfo {
|
|
6
|
+
get appType(): string {
|
|
7
|
+
return 'Browser-Client-SDK';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
platformData(): IPlatformData {
|
|
11
|
+
return {
|
|
12
|
+
os: {},
|
|
13
|
+
name: 'Browser',
|
|
14
|
+
additional: {},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
sdkData(): ISdkData {
|
|
19
|
+
return {
|
|
20
|
+
name: name,
|
|
21
|
+
version: version,
|
|
22
|
+
userAgentBase: this.appType
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|