@featbit/js-client-sdk 3.0.13 → 3.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +301 -301
- package/dist/esm/IFbClientCore.d.ts +1 -1
- package/dist/esm/IFbClientCore.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/{featbit-js-client-sdk-3.0.13.js → featbit-js-client-sdk-3.0.14.js} +2 -2
- package/dist/umd/featbit-js-client-sdk-3.0.14.js.map +1 -0
- package/dist/umd/featbit-js-client-sdk.js +1 -1
- package/dist/umd/featbit-js-client-sdk.js.map +1 -1
- package/package.json +46 -46
- package/src/Configuration.ts +232 -232
- package/src/Context.ts +61 -61
- package/src/FbClientBuilder.ts +167 -167
- package/src/FbClientCore.ts +405 -405
- package/src/IContextProperty.ts +3 -3
- package/src/IDataKind.ts +11 -11
- package/src/IFbClient.ts +29 -29
- package/src/IFbClientCore.ts +290 -290
- package/src/IVersionedData.ts +18 -18
- package/src/bootstrap/IBootstrapProvider.ts +4 -4
- package/src/bootstrap/JsonBootstrapProvider.ts +34 -34
- package/src/bootstrap/NullBootstrapProvider.ts +20 -20
- package/src/bootstrap/index.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/data-sources/DataSourceUpdates.ts +116 -116
- package/src/data-sources/createStreamListeners.ts +67 -67
- package/src/data-sources/index.ts +1 -1
- package/src/data-sync/DataSyncMode.ts +3 -3
- package/src/data-sync/IDataSynchronizer.ts +15 -15
- package/src/data-sync/IRequestor.ts +10 -10
- package/src/data-sync/NullDataSynchronizer.ts +14 -14
- package/src/data-sync/PollingDataSynchronizer.ts +125 -125
- package/src/data-sync/Requestor.ts +61 -61
- package/src/data-sync/WebSocketDataSynchronizer.ts +77 -77
- package/src/data-sync/index.ts +8 -8
- package/src/data-sync/types.ts +19 -19
- package/src/data-sync/utils.ts +31 -31
- package/src/errors.ts +47 -47
- package/src/evaluation/EvalResult.ts +35 -35
- package/src/evaluation/Evaluator.ts +26 -26
- package/src/evaluation/IEvalDetail.ts +23 -23
- package/src/evaluation/ReasonKinds.ts +9 -9
- package/src/evaluation/data/IFlag.ts +29 -29
- package/src/evaluation/index.ts +4 -4
- package/src/events/DefaultEventProcessor.ts +83 -83
- package/src/events/DefaultEventQueue.ts +49 -49
- package/src/events/DefaultEventSender.ts +73 -73
- package/src/events/DefaultEventSerializer.ts +11 -11
- package/src/events/EventDispatcher.ts +127 -127
- package/src/events/EventSerializer.ts +4 -4
- package/src/events/IEventProcessor.ts +8 -8
- package/src/events/IEventQueue.ts +16 -16
- package/src/events/IEventSender.ts +13 -13
- package/src/events/NullEventProcessor.ts +15 -15
- package/src/events/event.ts +129 -129
- package/src/events/index.ts +11 -11
- package/src/index.ts +21 -21
- package/src/integrations/TestLogger.ts +24 -24
- package/src/integrations/index.ts +1 -1
- package/src/integrations/test_data/FlagBuilder.ts +59 -59
- package/src/integrations/test_data/TestData.ts +57 -57
- package/src/integrations/test_data/TestDataSynchronizer.ts +49 -49
- package/src/integrations/test_data/index.ts +4 -4
- package/src/logging/BasicLogger.ts +108 -108
- package/src/logging/IBasicLoggerOptions.ts +46 -46
- package/src/logging/ILogger.ts +49 -49
- package/src/logging/LogLevel.ts +8 -8
- package/src/logging/SafeLogger.ts +69 -69
- package/src/logging/format.ts +154 -154
- package/src/logging/index.ts +5 -5
- package/src/options/ClientContext.ts +39 -39
- package/src/options/IClientContext.ts +53 -53
- package/src/options/IOptions.ts +123 -123
- package/src/options/IUser.ts +6 -6
- package/src/options/IValidatedOptions.ts +29 -29
- package/src/options/OptionMessages.ts +35 -35
- package/src/options/UserBuilder.ts +35 -35
- package/src/options/Validators.ts +300 -300
- package/src/options/index.ts +7 -7
- package/src/platform/IInfo.ts +102 -102
- package/src/platform/IPlatform.ts +20 -20
- package/src/platform/IStore.ts +112 -112
- package/src/platform/IWebSocket.ts +22 -22
- package/src/platform/browser/BrowserInfo.ts +24 -24
- package/src/platform/browser/BrowserPlatform.ts +19 -19
- package/src/platform/browser/BrowserRequests.ts +6 -6
- package/src/platform/browser/BrowserWebSocket.ts +147 -147
- package/src/platform/browser/FbClient.ts +65 -65
- package/src/platform/browser/LocalStorageStore.ts +59 -59
- package/src/platform/index.ts +11 -11
- package/src/platform/requests.ts +76 -76
- package/src/store/BaseStore.ts +125 -125
- package/src/store/DataKinds.ts +6 -6
- package/src/store/IDataSourceUpdates.ts +68 -68
- package/src/store/InMemoryStore.ts +36 -36
- package/src/store/index.ts +5 -5
- package/src/store/serialization.ts +52 -52
- package/src/store/store.ts +37 -37
- package/src/utils/Emits.ts +75 -75
- package/src/utils/EventEmitter.ts +128 -128
- package/src/utils/IEventEmitter.ts +14 -14
- package/src/utils/Regex.ts +21 -21
- package/src/utils/ValueConverters.ts +55 -55
- package/src/utils/canonicalizeUri.ts +3 -3
- package/src/utils/debounce.ts +33 -33
- package/src/utils/http.ts +40 -40
- package/src/utils/index.ts +5 -5
- package/src/utils/isNullOrUndefined.ts +2 -2
- package/src/utils/serializeUser.ts +27 -27
- package/src/utils/sleep.ts +5 -5
- package/src/version.ts +1 -1
- package/dist/umd/featbit-js-client-sdk-3.0.13.js.map +0 -1
package/src/platform/IInfo.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
export interface IFbDevice {
|
|
2
|
-
manufacturer?: string;
|
|
3
|
-
model?: string;
|
|
4
|
-
storageBytes?: string;
|
|
5
|
-
memoryBytes?: string;
|
|
6
|
-
os?: {
|
|
7
|
-
/**
|
|
8
|
-
* The family of operating system.
|
|
9
|
-
*/
|
|
10
|
-
family?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
version?: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Information about the platform of the SDK and the environment it is executing.
|
|
18
|
-
*/
|
|
19
|
-
export interface IPlatformData {
|
|
20
|
-
/**
|
|
21
|
-
* Information about the OS on which the SDK is running. Should be populated
|
|
22
|
-
* when available. Not all platforms will make this data accessible.
|
|
23
|
-
*/
|
|
24
|
-
os?: {
|
|
25
|
-
/**
|
|
26
|
-
* The architecture. Ideally at runtime, but may be build time if that is
|
|
27
|
-
* a constraint.
|
|
28
|
-
*/
|
|
29
|
-
arch?: string;
|
|
30
|
-
/**
|
|
31
|
-
* The name of the OS. "MacOS", "Windows", or "Linux". If not one of those,
|
|
32
|
-
* then use the value provided by the OS.
|
|
33
|
-
*/
|
|
34
|
-
name?: string;
|
|
35
|
-
|
|
36
|
-
/** The version of the OS. */
|
|
37
|
-
version?: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The name of the platform the SDK is running on. For instance 'Node'.
|
|
42
|
-
*/
|
|
43
|
-
name?: string;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Any additional attributes associated with the platform.
|
|
47
|
-
*/
|
|
48
|
-
additional?: Record<string, string>;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Device hardware information. Should be populated when available. Not all
|
|
52
|
-
* platforms will have this data.
|
|
53
|
-
*/
|
|
54
|
-
fbDevice?: IFbDevice;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ISdkData {
|
|
58
|
-
/**
|
|
59
|
-
* The name of the SDK. e.g. "browser-server-sdk"
|
|
60
|
-
*/
|
|
61
|
-
name?: string;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The version of the SDK.
|
|
65
|
-
*/
|
|
66
|
-
version?: string;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* If this is a top-level (not a wrapper) SDK this will be used to create the user agent string.
|
|
70
|
-
* It will take the form 'userAgentBase/version`.
|
|
71
|
-
*/
|
|
72
|
-
userAgent?: string;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Name of the wrapper SDK if present.
|
|
76
|
-
*/
|
|
77
|
-
wrapperName?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Version of the wrapper if present.
|
|
80
|
-
*/
|
|
81
|
-
wrapperVersion?: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Interface for getting information about the SDK or the environment it is
|
|
86
|
-
* executing in.
|
|
87
|
-
*/
|
|
88
|
-
export interface IInfo {
|
|
89
|
-
/**
|
|
90
|
-
* Get the app type
|
|
91
|
-
*/
|
|
92
|
-
get appType(): string;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get information about the platform.
|
|
96
|
-
*/
|
|
97
|
-
platformData(): IPlatformData;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Get information about the SDK implementation.
|
|
101
|
-
*/
|
|
102
|
-
sdkData(): ISdkData;
|
|
1
|
+
export interface IFbDevice {
|
|
2
|
+
manufacturer?: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
storageBytes?: string;
|
|
5
|
+
memoryBytes?: string;
|
|
6
|
+
os?: {
|
|
7
|
+
/**
|
|
8
|
+
* The family of operating system.
|
|
9
|
+
*/
|
|
10
|
+
family?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Information about the platform of the SDK and the environment it is executing.
|
|
18
|
+
*/
|
|
19
|
+
export interface IPlatformData {
|
|
20
|
+
/**
|
|
21
|
+
* Information about the OS on which the SDK is running. Should be populated
|
|
22
|
+
* when available. Not all platforms will make this data accessible.
|
|
23
|
+
*/
|
|
24
|
+
os?: {
|
|
25
|
+
/**
|
|
26
|
+
* The architecture. Ideally at runtime, but may be build time if that is
|
|
27
|
+
* a constraint.
|
|
28
|
+
*/
|
|
29
|
+
arch?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The name of the OS. "MacOS", "Windows", or "Linux". If not one of those,
|
|
32
|
+
* then use the value provided by the OS.
|
|
33
|
+
*/
|
|
34
|
+
name?: string;
|
|
35
|
+
|
|
36
|
+
/** The version of the OS. */
|
|
37
|
+
version?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The name of the platform the SDK is running on. For instance 'Node'.
|
|
42
|
+
*/
|
|
43
|
+
name?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Any additional attributes associated with the platform.
|
|
47
|
+
*/
|
|
48
|
+
additional?: Record<string, string>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Device hardware information. Should be populated when available. Not all
|
|
52
|
+
* platforms will have this data.
|
|
53
|
+
*/
|
|
54
|
+
fbDevice?: IFbDevice;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ISdkData {
|
|
58
|
+
/**
|
|
59
|
+
* The name of the SDK. e.g. "browser-server-sdk"
|
|
60
|
+
*/
|
|
61
|
+
name?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The version of the SDK.
|
|
65
|
+
*/
|
|
66
|
+
version?: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* If this is a top-level (not a wrapper) SDK this will be used to create the user agent string.
|
|
70
|
+
* It will take the form 'userAgentBase/version`.
|
|
71
|
+
*/
|
|
72
|
+
userAgent?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Name of the wrapper SDK if present.
|
|
76
|
+
*/
|
|
77
|
+
wrapperName?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Version of the wrapper if present.
|
|
80
|
+
*/
|
|
81
|
+
wrapperVersion?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Interface for getting information about the SDK or the environment it is
|
|
86
|
+
* executing in.
|
|
87
|
+
*/
|
|
88
|
+
export interface IInfo {
|
|
89
|
+
/**
|
|
90
|
+
* Get the app type
|
|
91
|
+
*/
|
|
92
|
+
get appType(): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get information about the platform.
|
|
96
|
+
*/
|
|
97
|
+
platformData(): IPlatformData;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get information about the SDK implementation.
|
|
101
|
+
*/
|
|
102
|
+
sdkData(): ISdkData;
|
|
103
103
|
}
|
|
@@ -1,21 +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;
|
|
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
21
|
}
|
package/src/platform/IStore.ts
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
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): Promise<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
|
-
init(allData: IStoreDataStorage): Promise<void>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Add an entity or update an existing entity.
|
|
74
|
-
*
|
|
75
|
-
* @param kind
|
|
76
|
-
* The type of data to be accessed. The actual type of this parameter is
|
|
77
|
-
* {@link IDataKind}.
|
|
78
|
-
*
|
|
79
|
-
* @param data
|
|
80
|
-
* The contents of the entity, as an object that can be converted to JSON. The store
|
|
81
|
-
* should check the `version` property of this object, and should *not* overwrite any
|
|
82
|
-
* existing data if the existing `version` is greater than or equal to that value.
|
|
83
|
-
* The actual type of this parameter is {@link IKeyedStoreItem}.
|
|
84
|
-
*/
|
|
85
|
-
upsert(kind: IDataKind, data: IKeyedStoreItem): Promise<void>;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Tests whether the store is initialized.
|
|
89
|
-
*
|
|
90
|
-
* "Initialized" means that the store has been populated with data, either by the client
|
|
91
|
-
* having called `init()` within this process, or by another process (if this is a shared
|
|
92
|
-
* database).
|
|
93
|
-
*
|
|
94
|
-
* @param callback
|
|
95
|
-
* Will be called back with the boolean result.
|
|
96
|
-
*/
|
|
97
|
-
initialized(): boolean;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Releases any resources being used by the feature store.
|
|
101
|
-
*/
|
|
102
|
-
close(): void;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get a description of the store.
|
|
106
|
-
*/
|
|
107
|
-
getDescription?(): string;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The current version of the store.
|
|
111
|
-
*/
|
|
112
|
-
version: number;
|
|
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): Promise<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
|
+
init(allData: IStoreDataStorage): Promise<void>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Add an entity or update an existing entity.
|
|
74
|
+
*
|
|
75
|
+
* @param kind
|
|
76
|
+
* The type of data to be accessed. The actual type of this parameter is
|
|
77
|
+
* {@link IDataKind}.
|
|
78
|
+
*
|
|
79
|
+
* @param data
|
|
80
|
+
* The contents of the entity, as an object that can be converted to JSON. The store
|
|
81
|
+
* should check the `version` property of this object, and should *not* overwrite any
|
|
82
|
+
* existing data if the existing `version` is greater than or equal to that value.
|
|
83
|
+
* The actual type of this parameter is {@link IKeyedStoreItem}.
|
|
84
|
+
*/
|
|
85
|
+
upsert(kind: IDataKind, data: IKeyedStoreItem): Promise<void>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Tests whether the store is initialized.
|
|
89
|
+
*
|
|
90
|
+
* "Initialized" means that the store has been populated with data, either by the client
|
|
91
|
+
* having called `init()` within this process, or by another process (if this is a shared
|
|
92
|
+
* database).
|
|
93
|
+
*
|
|
94
|
+
* @param callback
|
|
95
|
+
* Will be called back with the boolean result.
|
|
96
|
+
*/
|
|
97
|
+
initialized(): boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Releases any resources being used by the feature store.
|
|
101
|
+
*/
|
|
102
|
+
close(): void;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get a description of the store.
|
|
106
|
+
*/
|
|
107
|
+
getDescription?(): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The current version of the store.
|
|
111
|
+
*/
|
|
112
|
+
version: number;
|
|
113
113
|
}
|
|
@@ -1,23 +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 {
|
|
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
23
|
}
|
|
@@ -1,25 +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
|
-
userAgent: `${ this.appType }/${ version }`,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
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
|
+
userAgent: `${ this.appType }/${ version }`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
25
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IPlatform } from "../IPlatform";
|
|
2
|
-
import { IInfo } from "../IInfo";
|
|
3
|
-
import { IRequests } from "../requests";
|
|
4
|
-
import { IOptions } from "../../options/IOptions";
|
|
5
|
-
import BrowserInfo from "./BrowserInfo";
|
|
6
|
-
import { BrowserRequests } from "./BrowserRequests";
|
|
7
|
-
import { IWebSocketWithEvents } from "../IWebSocket";
|
|
8
|
-
import BrowserWebSocket from "./BrowserWebSocket";
|
|
9
|
-
|
|
10
|
-
export class BrowserPlatform implements IPlatform {
|
|
11
|
-
info: IInfo = new BrowserInfo();
|
|
12
|
-
|
|
13
|
-
requests: IRequests;
|
|
14
|
-
webSocket: IWebSocketWithEvents;
|
|
15
|
-
|
|
16
|
-
constructor(options: IOptions) {
|
|
17
|
-
this.requests = new BrowserRequests();
|
|
18
|
-
this.webSocket = new BrowserWebSocket();
|
|
19
|
-
}
|
|
1
|
+
import { IPlatform } from "../IPlatform";
|
|
2
|
+
import { IInfo } from "../IInfo";
|
|
3
|
+
import { IRequests } from "../requests";
|
|
4
|
+
import { IOptions } from "../../options/IOptions";
|
|
5
|
+
import BrowserInfo from "./BrowserInfo";
|
|
6
|
+
import { BrowserRequests } from "./BrowserRequests";
|
|
7
|
+
import { IWebSocketWithEvents } from "../IWebSocket";
|
|
8
|
+
import BrowserWebSocket from "./BrowserWebSocket";
|
|
9
|
+
|
|
10
|
+
export class BrowserPlatform implements IPlatform {
|
|
11
|
+
info: IInfo = new BrowserInfo();
|
|
12
|
+
|
|
13
|
+
requests: IRequests;
|
|
14
|
+
webSocket: IWebSocketWithEvents;
|
|
15
|
+
|
|
16
|
+
constructor(options: IOptions) {
|
|
17
|
+
this.requests = new BrowserRequests();
|
|
18
|
+
this.webSocket = new BrowserWebSocket();
|
|
19
|
+
}
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IRequestOptions, IRequests } from "../requests";
|
|
2
|
-
|
|
3
|
-
export class BrowserRequests implements IRequests {
|
|
4
|
-
fetch(url: string, options: IRequestOptions = {}): Promise<any> {
|
|
5
|
-
return fetch(url, options);
|
|
6
|
-
}
|
|
1
|
+
import { IRequestOptions, IRequests } from "../requests";
|
|
2
|
+
|
|
3
|
+
export class BrowserRequests implements IRequests {
|
|
4
|
+
fetch(url: string, options: IRequestOptions = {}): Promise<any> {
|
|
5
|
+
return fetch(url, options);
|
|
6
|
+
}
|
|
7
7
|
}
|