@configdirector/react-native-sdk 1.7.0 → 1.9.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/README.md +6 -4
- package/dist/configdirector-react-native-testing.d.mts +5 -14
- package/dist/configdirector-react-native-testing.mjs +8 -105
- package/dist/configdirector-react-native.d.mts +24 -6
- package/dist/configdirector-react-native.mjs +65 -35
- package/dist/{installedTestClient-LWv5ji8J.mjs → installedTestClient-BluKT8Qj.mjs} +579 -94
- package/dist/{types-P1hoU2Ru.d.mts → types-BBQmjjf5.d.mts} +123 -39
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ interface ConfigDirectorLogger {
|
|
|
23
23
|
interface ConfigDirectorLogMessageDecorator {
|
|
24
24
|
decorateMessage(message: string): string;
|
|
25
25
|
}
|
|
26
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean";
|
|
26
|
+
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
27
27
|
type ConfigEvaluation = {
|
|
28
28
|
key: string;
|
|
29
29
|
value: ConfigValueType;
|
|
@@ -42,9 +42,11 @@ type ConfigDirectorContext = {
|
|
|
42
42
|
* The context's identifier. This should be a value that uniquely identifies the user or other
|
|
43
43
|
* entity among contexts of the same {@link kind}.
|
|
44
44
|
* In the case of anonymous users, you could generate a UUID or alternatively not provide
|
|
45
|
-
* the {@link id}
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* the {@link id}. In a client SDK, ConfigDirector then derives an identifier from an ID the SDK
|
|
46
|
+
* stores for the app install or the website, so it stays the same until the app is uninstalled
|
|
47
|
+
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
48
|
+
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
49
|
+
* being assigned to a different percentile.
|
|
48
50
|
*/
|
|
49
51
|
id?: string;
|
|
50
52
|
/**
|
|
@@ -88,9 +90,115 @@ type ConfigDirectorMetaContext = {
|
|
|
88
90
|
appVersion?: string;
|
|
89
91
|
appName?: string;
|
|
90
92
|
};
|
|
91
|
-
type ConnectionMode = "streaming" | "polling";
|
|
93
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region ../shared/src/native-values.d.ts
|
|
96
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
97
|
+
[key: string]: NativeJsonValue;
|
|
98
|
+
};
|
|
99
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
100
|
+
[key: string]: NativeJsonValue;
|
|
101
|
+
};
|
|
102
|
+
type NativeValues = Record<string, NativeValue>;
|
|
92
103
|
//#endregion
|
|
93
104
|
//#region ../js-client-core/src/types.d.ts
|
|
105
|
+
/**
|
|
106
|
+
* A store for the values the client keeps on the device between launches. One provider instance
|
|
107
|
+
* serves one client: the provider decides where the entry lives, and the SDK owns the entry's
|
|
108
|
+
* format, which may change between SDK versions.
|
|
109
|
+
*/
|
|
110
|
+
type CachingProvider = {
|
|
111
|
+
/**
|
|
112
|
+
* Returns the stored entry, or `null` or `undefined` when nothing is stored.
|
|
113
|
+
*/
|
|
114
|
+
read(): string | null | undefined | Promise<string | null | undefined>;
|
|
115
|
+
/**
|
|
116
|
+
* Replaces the stored entry. The SDK never writes an entry larger than {@link sizeLimit}.
|
|
117
|
+
*/
|
|
118
|
+
write(value: string): void | Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Removes the stored entry.
|
|
121
|
+
*/
|
|
122
|
+
remove(): void | Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* The largest entry, in UTF-8 bytes, the provider accepts. When the values received from
|
|
125
|
+
* ConfigDirector exceed it, the SDK removes the stored entry and keeps nothing on the device.
|
|
126
|
+
*/
|
|
127
|
+
sizeLimit(): number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Options for the values the client keeps on the device, served on the next launch of the same
|
|
131
|
+
* context until live values arrive. Ignored in `offline` mode.
|
|
132
|
+
*/
|
|
133
|
+
type CachingOptions = {
|
|
134
|
+
/**
|
|
135
|
+
* Whether to keep the last values received on the device. Defaults to `true`.
|
|
136
|
+
*/
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The store for the values. Defaults to the platform's own store: `localStorage` in the
|
|
140
|
+
* browser, AsyncStorage on React Native.
|
|
141
|
+
*/
|
|
142
|
+
provider?: CachingProvider;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
146
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
147
|
+
* or array (`json`).
|
|
148
|
+
*/
|
|
149
|
+
type OfflineValue = NativeValue;
|
|
150
|
+
/**
|
|
151
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
152
|
+
* value's config type is decided. Every context receives the same value.
|
|
153
|
+
*/
|
|
154
|
+
type OfflineValues = NativeValues;
|
|
155
|
+
/**
|
|
156
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
157
|
+
*/
|
|
158
|
+
type ConnectionOptions = {
|
|
159
|
+
/**
|
|
160
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
161
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
162
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
163
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
164
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
165
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
166
|
+
* the values given in {@link values} to every context, or the in-code default values when none
|
|
167
|
+
* are given. No SDK key is needed.
|
|
168
|
+
*
|
|
169
|
+
* Defaults to `streaming`
|
|
170
|
+
*/
|
|
171
|
+
mode?: ConnectionMode;
|
|
172
|
+
/**
|
|
173
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
174
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
175
|
+
*
|
|
176
|
+
* Can be given only in `offline` mode; otherwise `initialize` rejects.
|
|
177
|
+
*/
|
|
178
|
+
values?: OfflineValues;
|
|
179
|
+
/**
|
|
180
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
181
|
+
* effect in the other modes.
|
|
182
|
+
*
|
|
183
|
+
* Defaults to 60 seconds. The minimum is 30 seconds. A value below the minimum is raised to the
|
|
184
|
+
* minimum and a warning is logged.
|
|
185
|
+
*/
|
|
186
|
+
pollingInterval?: number;
|
|
187
|
+
/**
|
|
188
|
+
* The timeout, in _milliseconds_, to be used in initialization and when updating the context.
|
|
189
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
190
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
191
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
192
|
+
* no effect in `offline` mode.
|
|
193
|
+
*/
|
|
194
|
+
timeout?: number;
|
|
195
|
+
/**
|
|
196
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
197
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
198
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
199
|
+
*/
|
|
200
|
+
url?: string;
|
|
201
|
+
};
|
|
94
202
|
/**
|
|
95
203
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
96
204
|
*/
|
|
@@ -102,39 +210,13 @@ type ConfigDirectorClientOptions = {
|
|
|
102
210
|
/**
|
|
103
211
|
* Connection options
|
|
104
212
|
*/
|
|
105
|
-
connection?:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
* Defaults to `streaming`
|
|
114
|
-
*/
|
|
115
|
-
mode?: ConnectionMode;
|
|
116
|
-
/**
|
|
117
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
118
|
-
* effect when the `mode` is set to `streaming`.
|
|
119
|
-
*
|
|
120
|
-
* Defaults to 60 seconds. The minimum is 30 seconds. A value below the minimum is raised to the
|
|
121
|
-
* minimum and a warning is logged.
|
|
122
|
-
*/
|
|
123
|
-
pollingInterval?: number;
|
|
124
|
-
/**
|
|
125
|
-
* The timeout, in _milliseconds_, to be used in initialization and when updating the context.
|
|
126
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
127
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
128
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
129
|
-
*/
|
|
130
|
-
timeout?: number;
|
|
131
|
-
/**
|
|
132
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
133
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
134
|
-
* a proxy for the client SDK.
|
|
135
|
-
*/
|
|
136
|
-
url?: string;
|
|
137
|
-
};
|
|
213
|
+
connection?: ConnectionOptions;
|
|
214
|
+
/**
|
|
215
|
+
* Options for the values the client keeps on the device between launches. The last values
|
|
216
|
+
* received are kept by default and served, with the evaluation reason `cached`, on the next
|
|
217
|
+
* launch of the same context until live values arrive. See {@link CachingOptions}.
|
|
218
|
+
*/
|
|
219
|
+
caching?: CachingOptions;
|
|
138
220
|
/**
|
|
139
221
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
140
222
|
* logger set to 'warn' level.
|
|
@@ -172,6 +254,7 @@ type ClientHooks = {
|
|
|
172
254
|
contextUpdated?: HookHandler<"contextUpdated"> | HookHandler<"contextUpdated">[];
|
|
173
255
|
configEvaluated?: HookHandler<"configEvaluated"> | HookHandler<"configEvaluated">[];
|
|
174
256
|
connectionError?: HookHandler<"connectionError"> | HookHandler<"connectionError">[];
|
|
257
|
+
cachedValuesLoaded?: HookHandler<"cachedValuesLoaded"> | HookHandler<"cachedValuesLoaded">[];
|
|
175
258
|
};
|
|
176
259
|
type ClientConnectAction = "initialization" | "context update" | "network resume";
|
|
177
260
|
type HookHandler<TEvent extends keyof ClientEvents> = (payload: ClientEvents[TEvent]) => void;
|
|
@@ -192,6 +275,7 @@ type ClientEvents = {
|
|
|
192
275
|
connectionError: {
|
|
193
276
|
error: Error;
|
|
194
277
|
};
|
|
278
|
+
cachedValuesLoaded: Record<string, never>;
|
|
195
279
|
};
|
|
196
280
|
type WatchHandler<T extends ConfigValueType> = (message: T) => void;
|
|
197
281
|
/**
|
|
@@ -313,4 +397,4 @@ interface ConfigDirectorClient extends EventProvider<ClientEvents> {
|
|
|
313
397
|
dispose(): void;
|
|
314
398
|
}
|
|
315
399
|
//#endregion
|
|
316
|
-
export {
|
|
400
|
+
export { ConfigDirectorClientOptions as a, NativeJsonValue as c, ConfigDirectorContext as d, ConfigDirectorLogMessageDecorator as f, ConnectionMode as g, ConfigValueType as h, ConfigDirectorClient as i, NativeValue as l, ConfigDirectorLoggingLevel as m, CachingProvider as n, OfflineValue as o, ConfigDirectorLogger as p, ClientHooks as r, OfflineValues as s, CachingOptions as t, NativeValues as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configdirector/react-native-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "React Native client SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ConfigDirector",
|