@configdirector/react-native-sdk 1.3.0 → 1.5.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 +37 -2
- package/dist/configdirector-react-native.mjs +25 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# ConfigDirector React Native SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![npm][npm-badge]][npm]
|
|
4
|
+
|
|
5
|
+
React Native SDK for [ConfigDirector](https://www.configdirector.com), remote config and feature flags with typed values, JSON Schema validation, and safe renames of live flags. Start free, no card required.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save @configdirector/react-native-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Retrieve a value
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Text } from "react-native";
|
|
17
|
+
import { ConfigDirectorProvider, useConfigValue } from "@configdirector/react-native-sdk";
|
|
18
|
+
|
|
19
|
+
export default function App() {
|
|
20
|
+
return (
|
|
21
|
+
<ConfigDirectorProvider sdkKey="YOUR-CLIENT-SDK-KEY" appName="MyApp" appVersion="1.0.0">
|
|
22
|
+
<Home />
|
|
23
|
+
</ConfigDirectorProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Home() {
|
|
28
|
+
const { value: darkMode } = useConfigValue("dark-mode", false);
|
|
29
|
+
return <Text>dark-mode: {String(darkMode)}</Text>;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Full details are in the [official documentation](https://docs.configdirector.com/sdks/mobile/react-native).
|
|
4
34
|
|
|
5
35
|
## Documentation
|
|
6
36
|
|
|
@@ -10,4 +40,9 @@ There is also [a quickstart guide for ConfigDirector and any of our SDKs](https:
|
|
|
10
40
|
|
|
11
41
|
## Getting Help
|
|
12
42
|
|
|
13
|
-
|
|
43
|
+
- [Ask a question in Discussions](https://github.com/orgs/ConfigDirector/discussions)
|
|
44
|
+
- [Contact support](https://www.configdirector.com/support)
|
|
45
|
+
|
|
46
|
+
[//]: # "links"
|
|
47
|
+
[npm-badge]: https://img.shields.io/npm/v/@configdirector/react-native-sdk.svg
|
|
48
|
+
[npm]: https://www.npmjs.com/package/@configdirector/react-native-sdk
|
|
@@ -511,7 +511,7 @@ var StreamingTransport = class {
|
|
|
511
511
|
return new ConfigDirectorConnectionError(`${`Connection failed with status: ${responseStatus !== null && responseStatus !== void 0 ? responseStatus : "unknown"}.`}${error ? ` Error: ${error}` : ""}. This is an unrecoverable error, will not attempt to reconnect.`, status);
|
|
512
512
|
}
|
|
513
513
|
isStatusFatal(status) {
|
|
514
|
-
return !!status && status >= 400 && status < 500;
|
|
514
|
+
return !!status && status >= 400 && status < 500 && status != 429;
|
|
515
515
|
}
|
|
516
516
|
on(name, handler) {
|
|
517
517
|
this.eventEmitter.on(name, handler);
|
|
@@ -553,6 +553,11 @@ const getRequestedType = (defaultValue) => {
|
|
|
553
553
|
const isNumericNativeType = (requestedType) => {
|
|
554
554
|
return requestedType === "number" || requestedType === "bigint";
|
|
555
555
|
};
|
|
556
|
+
const configTypesNotReadableAsString = new Set([
|
|
557
|
+
"boolean",
|
|
558
|
+
"integer",
|
|
559
|
+
"float"
|
|
560
|
+
]);
|
|
556
561
|
const parseConfigValue = (configState, defaultValue) => {
|
|
557
562
|
const value = configState.value;
|
|
558
563
|
const requestedType = getRequestedType(defaultValue);
|
|
@@ -564,13 +569,22 @@ const parseConfigValue = (configState, defaultValue) => {
|
|
|
564
569
|
reason: "value-missing"
|
|
565
570
|
};
|
|
566
571
|
if (configState.type === "json") return parseJson(value, defaultValue, requestedType, configState.valueId);
|
|
567
|
-
if (typeof defaultValue === "string")
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
572
|
+
if (typeof defaultValue === "string") {
|
|
573
|
+
if (configTypesNotReadableAsString.has(configState.type)) return {
|
|
574
|
+
parsedValue: defaultValue,
|
|
575
|
+
parsedValueId: void 0,
|
|
576
|
+
requestedType,
|
|
577
|
+
usedDefault: true,
|
|
578
|
+
reason: "type-mismatch"
|
|
579
|
+
};
|
|
580
|
+
return {
|
|
581
|
+
parsedValue: value,
|
|
582
|
+
parsedValueId: configState.valueId,
|
|
583
|
+
requestedType,
|
|
584
|
+
usedDefault: false,
|
|
585
|
+
reason: "found-match"
|
|
586
|
+
};
|
|
587
|
+
}
|
|
574
588
|
if (typeof defaultValue === "boolean" && (configState.type === "boolean" || configState.type === "string" || configState.type === "enum")) {
|
|
575
589
|
const boolValue = parseConfigBoolean(value);
|
|
576
590
|
const hasBoolean = typeof boolValue === "boolean";
|
|
@@ -879,7 +893,7 @@ var AbstractPollingTransport = class {
|
|
|
879
893
|
return new ConfigDirectorConnectionError(`${`Connection failed with status: ${responseStatus !== null && responseStatus !== void 0 ? responseStatus : "unknown"}`}${((_errorBody$trim$lengt = errorBody === null || errorBody === void 0 || (_errorBody$trim = errorBody.trim()) === null || _errorBody$trim === void 0 ? void 0 : _errorBody$trim.length) !== null && _errorBody$trim$lengt !== void 0 ? _errorBody$trim$lengt : 0) > 0 ? ` (${errorBody})` : ""}. This is an unrecoverable error, retry attempts will be ignored.`, status);
|
|
880
894
|
}
|
|
881
895
|
isStatusFatal(status) {
|
|
882
|
-
return !!status && status >= 400 && status < 500;
|
|
896
|
+
return !!status && status >= 400 && status < 500 && status != 429;
|
|
883
897
|
}
|
|
884
898
|
isFetchErrorFatal(fetchError) {
|
|
885
899
|
return (fetchError === null || fetchError === void 0 ? void 0 : fetchError.name) === "NotAllowedError";
|
|
@@ -1404,7 +1418,7 @@ var ClientEventReporter = class {
|
|
|
1404
1418
|
}
|
|
1405
1419
|
}
|
|
1406
1420
|
isStatusFatal(status) {
|
|
1407
|
-
return !!status && status >= 400 && status < 500;
|
|
1421
|
+
return !!status && status >= 400 && status < 500 && status != 429;
|
|
1408
1422
|
}
|
|
1409
1423
|
};
|
|
1410
1424
|
//#endregion
|
|
@@ -1801,7 +1815,7 @@ const createClient = (clientSdkKey, clientOptions) => {
|
|
|
1801
1815
|
var _clientOptions$logger, _clientOptions$connec;
|
|
1802
1816
|
const sdkIdentity = {
|
|
1803
1817
|
sdkName: "react-native-sdk",
|
|
1804
|
-
sdkVersion: "1.
|
|
1818
|
+
sdkVersion: "1.5.0"
|
|
1805
1819
|
};
|
|
1806
1820
|
const logger = (_clientOptions$logger = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.logger) !== null && _clientOptions$logger !== void 0 ? _clientOptions$logger : createConsoleLogger("warn");
|
|
1807
1821
|
return new DefaultConfigDirectorClient(new ReactNativeTelemetryClient({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configdirector/react-native-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|