@featbit/openfeature-provider-node-server 1.0.0 → 1.0.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featbit/openfeature-provider-node-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A OpenFeature provider implementation for the FeatBit node SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/featbit/openfeature-provider-node-server#readme",
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@featbit/node-server-sdk": "^1.
|
|
25
|
-
"@openfeature/server-sdk": "
|
|
24
|
+
"@featbit/node-server-sdk": "^1.1.2",
|
|
25
|
+
"@openfeature/server-sdk": "1.9.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@featbit/node-server-sdk": "^1.
|
|
29
|
-
"@openfeature/server-sdk": "
|
|
28
|
+
"@featbit/node-server-sdk": "^1.1.2",
|
|
29
|
+
"@openfeature/server-sdk": "1.9.0",
|
|
30
30
|
"@types/jest": "^29.5.11",
|
|
31
31
|
"jest": "^29.7.0",
|
|
32
32
|
"rimraf": "^5.0.5",
|
package/src/FbProvider.ts
CHANGED
|
@@ -48,9 +48,9 @@ export class FbProvider implements Provider {
|
|
|
48
48
|
|
|
49
49
|
try {
|
|
50
50
|
this.client = new FbClientBuilder(options).build();
|
|
51
|
-
this.client.on('update', (
|
|
52
|
-
|
|
53
|
-
})
|
|
51
|
+
this.client.on('update', (keys: string[]) => {
|
|
52
|
+
this.events.emit(ProviderEvents.ConfigurationChanged, {flagsChanged: keys})
|
|
53
|
+
})
|
|
54
54
|
} catch (err) {
|
|
55
55
|
this.clientConstructionError = err;
|
|
56
56
|
this.logger.error(`Encountered unrecoverable initialization error, ${ err }`);
|
package/tests/FbProvider.test.ts
CHANGED
|
@@ -80,6 +80,7 @@ it('emits events for flag changes', async () => {
|
|
|
80
80
|
expect(await provider.getClient()
|
|
81
81
|
.stringVariation('flagA', { key: 'test-key' }, 'false'))
|
|
82
82
|
.toEqual('true');
|
|
83
|
+
|
|
83
84
|
expect(count).toEqual(1);
|
|
84
85
|
await provider.onClose();
|
|
85
86
|
});
|
|
@@ -139,6 +140,7 @@ describe('given a mock FbClient', () => {
|
|
|
139
140
|
// String variations
|
|
140
141
|
it('calls the client correctly for string variations', async () => {
|
|
141
142
|
fbClient.evaluateCore<string> = jest.fn( () => ({
|
|
143
|
+
flagKey: testFlagKey,
|
|
142
144
|
kind: ReasonKinds.Off,
|
|
143
145
|
reason: '',
|
|
144
146
|
value: 'some value'
|
|
@@ -165,6 +167,7 @@ describe('given a mock FbClient', () => {
|
|
|
165
167
|
// Boolean variations
|
|
166
168
|
it('calls the client correctly for boolean variations', async () => {
|
|
167
169
|
fbClient.evaluateCore<boolean> = jest.fn( () => ({
|
|
170
|
+
flagKey: testFlagKey,
|
|
168
171
|
kind: ReasonKinds.Off,
|
|
169
172
|
reason: '',
|
|
170
173
|
value: true
|
|
@@ -202,6 +205,7 @@ describe('given a mock FbClient', () => {
|
|
|
202
205
|
// Numeric variations
|
|
203
206
|
it('calls the client correctly for numeric variations', async () => {
|
|
204
207
|
fbClient.evaluateCore<number> = jest.fn( () => ({
|
|
208
|
+
flagKey: testFlagKey,
|
|
205
209
|
kind: ReasonKinds.Off,
|
|
206
210
|
reason: '',
|
|
207
211
|
value: 1
|
|
@@ -239,6 +243,7 @@ describe('given a mock FbClient', () => {
|
|
|
239
243
|
// JSON variations
|
|
240
244
|
it('calls the client correctly for object variations', async () => {
|
|
241
245
|
fbClient.evaluateCore<any> = jest.fn( () => ({
|
|
246
|
+
flagKey: testFlagKey,
|
|
242
247
|
kind: ReasonKinds.Off,
|
|
243
248
|
reason: '',
|
|
244
249
|
value: { some: 'value' }
|
|
@@ -9,6 +9,7 @@ it.each([
|
|
|
9
9
|
{ yes: 'no' },
|
|
10
10
|
])('puts the value into the result.', (value) => {
|
|
11
11
|
const evalDetail: IEvalDetail<typeof value> = {
|
|
12
|
+
flagKey: "xxx",
|
|
12
13
|
value,
|
|
13
14
|
kind: ReasonKinds.FallThrough,
|
|
14
15
|
}
|
|
@@ -23,6 +24,7 @@ it.each([
|
|
|
23
24
|
ReasonKinds.RuleMatch
|
|
24
25
|
])('populates the resolution reason with kind', (kind: ReasonKinds) => {
|
|
25
26
|
expect(translateResult<boolean>({
|
|
27
|
+
flagKey: "xxx",
|
|
26
28
|
value: true,
|
|
27
29
|
kind
|
|
28
30
|
}).reason).toEqual(kind);
|
|
@@ -34,6 +36,7 @@ it.each([
|
|
|
34
36
|
[ReasonKinds.ClientNotReady, ErrorCode.PROVIDER_NOT_READY],
|
|
35
37
|
])('populates the resolution reason with error', (kind: ReasonKinds, expectedErrorCode) => {
|
|
36
38
|
const result = translateResult<boolean>({
|
|
39
|
+
flagKey: "xxx",
|
|
37
40
|
value: true,
|
|
38
41
|
kind
|
|
39
42
|
});
|
|
@@ -44,6 +47,7 @@ it.each([
|
|
|
44
47
|
|
|
45
48
|
it('does not populate the errorCode when there is not an error', () => {
|
|
46
49
|
const translated = translateResult<boolean>({
|
|
50
|
+
flagKey: "xxx",
|
|
47
51
|
value: true,
|
|
48
52
|
kind: ReasonKinds.FallThrough,
|
|
49
53
|
});
|