@reflag/openfeature-node-provider 1.0.0-alpha.1 → 1.0.0-alpha.3
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 +20 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,6 +18,19 @@ The minimum required version of `@reflag/node-sdk` currently is `2.0.0`.
|
|
|
18
18
|
npm install @openfeature/server-sdk @reflag/node-sdk
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Migrating from Bucket OpenFeature SDK
|
|
22
|
+
|
|
23
|
+
If you have been using the Bucket SDKs, the following list will help you migrate to Reflag SDK:
|
|
24
|
+
|
|
25
|
+
- `Bucket*` classes, and types have been renamed to `Reflag*` (e.g. `BucketClient` is now `ReflagClient`)
|
|
26
|
+
- All environment variables that were prefixed with `BUCKET_` are now prefixed with `REFLAG_`
|
|
27
|
+
- The `BUCKET_HOST` environment variable and `host` option have been removed from `ReflagClient` constructor, use `REFLAG_API_BASE_URL` instead
|
|
28
|
+
- The `BUCKET_FEATURES_ENABLED` and `BUCKET_FEATURES_DISABLED` have been renamed to `REFLAG_FLAGS_ENABLED` and `REFLAG_FLAGS_DISABLED`
|
|
29
|
+
- The default configuration file has been renamed from `bucketConfig.json` to `reflag.config.json`
|
|
30
|
+
- The `fallbackFeatures` property in client constructor and configuration files has been renamed to `fallbackFlags`
|
|
31
|
+
- `featureKey` has been renamed to `flagKey` in all methods that accepts that argument
|
|
32
|
+
- The SDKs will not emit `evaluate` and `evaluate-config` events anymore
|
|
33
|
+
|
|
21
34
|
## Usage
|
|
22
35
|
|
|
23
36
|
The provider uses the [Reflag Node.js SDK](https://docs.reflag.com/quickstart/supported-languages-frameworks/node.js-sdk).
|
|
@@ -46,7 +59,7 @@ const requestContext = {
|
|
|
46
59
|
|
|
47
60
|
const client = OpenFeature.getClient();
|
|
48
61
|
|
|
49
|
-
const
|
|
62
|
+
const enterpriseFlagEnabled = await client.getBooleanValue(
|
|
50
63
|
"enterpriseFlag",
|
|
51
64
|
false,
|
|
52
65
|
requestContext,
|
|
@@ -74,7 +87,7 @@ All resolution methods share these behaviors:
|
|
|
74
87
|
client.getBooleanValue("my-flag", false);
|
|
75
88
|
```
|
|
76
89
|
|
|
77
|
-
Returns the
|
|
90
|
+
Returns the flags's enabled state. This is the most common use case for flags.
|
|
78
91
|
|
|
79
92
|
#### String Resolution
|
|
80
93
|
|
|
@@ -82,7 +95,7 @@ Returns the feature's enabled state. This is the most common use case for flags.
|
|
|
82
95
|
client.getStringValue("my-flag", "default");
|
|
83
96
|
```
|
|
84
97
|
|
|
85
|
-
Returns the
|
|
98
|
+
Returns the flags's remote config key (also known as "variant"). Useful for multi-variate use cases.
|
|
86
99
|
|
|
87
100
|
#### Number Resolution
|
|
88
101
|
|
|
@@ -101,10 +114,10 @@ client.getObjectValue("my-flag", "string-value");
|
|
|
101
114
|
client.getObjectValue("my-flag", 199);
|
|
102
115
|
```
|
|
103
116
|
|
|
104
|
-
Returns the
|
|
117
|
+
Returns the flag's remote config payload with type validation. This is the most flexible method,
|
|
105
118
|
allowing for complex configuration objects or simple types.
|
|
106
119
|
|
|
107
|
-
The object resolution performs runtime type checking between the default value and the
|
|
120
|
+
The object resolution performs runtime type checking between the default value and the flag payload to ensure type safety.
|
|
108
121
|
|
|
109
122
|
## Translating Evaluation Context
|
|
110
123
|
|
|
@@ -113,7 +126,7 @@ Reflag uses a context object of the following shape:
|
|
|
113
126
|
```ts
|
|
114
127
|
/**
|
|
115
128
|
* Describes the current user context, company context, and other context.
|
|
116
|
-
* This is used to determine if
|
|
129
|
+
* This is used to determine if flag targeting matches and to track events.
|
|
117
130
|
**/
|
|
118
131
|
export type ReflagContext = {
|
|
119
132
|
/**
|
|
@@ -140,7 +153,7 @@ export type ReflagContext = {
|
|
|
140
153
|
```
|
|
141
154
|
|
|
142
155
|
To use the Reflag Node.js OpenFeature provider, you must convert your OpenFeature contexts to Reflag contexts.
|
|
143
|
-
You can achieve this by supplying a context translation function which takes the
|
|
156
|
+
You can achieve this by supplying a context translation function which takes the OpenFeature context and returns
|
|
144
157
|
a corresponding Reflag Context:
|
|
145
158
|
|
|
146
159
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reflag/openfeature-node-provider",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"vitest": "~1.6.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@reflag/node-sdk": "1.0.0-alpha.
|
|
53
|
+
"@reflag/node-sdk": "1.0.0-alpha.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@openfeature/server-sdk": ">=1.16.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "d82ab8460d83e490b4e6fd2a20897305445c7f06"
|
|
59
59
|
}
|