@openfeature/flagd-provider 0.8.1 → 0.8.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 CHANGED
@@ -1,4 +1,4 @@
1
- # Server-side flagd Provider
1
+ # Server-Side flagd Provider
2
2
 
3
3
  Flagd is a simple daemon for evaluating feature flags.
4
4
  It is designed to conform to OpenFeature schema for flag definitions.
@@ -21,19 +21,19 @@ $ npm install @openfeature/js-sdk
21
21
  The `FlagdProvider` supports multiple configuration options that determine now the SDK communicates with flagd.
22
22
  Options can be defined in the constructor or as environment variables, with constructor options having the highest precedence.
23
23
 
24
- ### Available options
24
+ ### Available Options
25
25
 
26
- | Option name | Environment variable name | Type | Default | Values |
27
- | --------------------- | ------------------------------- | ------- | --------- | ------------- |
28
- | host | FLAGD_HOST | string | localhost | |
29
- | port | FLAGD_PORT | number | 8013 | |
30
- | tls | FLAGD_TLS | boolean | false | |
31
- | socketPath | FLAGD_SOCKET_PATH | string | - | |
32
- | cache | FLAGD_CACHE | string | lru | lru,disabled |
33
- | maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
34
- | maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | |
26
+ | Option name | Environment variable name | Type | Default | Values |
27
+ | --------------------- | ------------------------------ | ------- | --------- | ------------ |
28
+ | host | FLAGD_HOST | string | localhost | |
29
+ | port | FLAGD_PORT | number | 8013 | |
30
+ | tls | FLAGD_TLS | boolean | false | |
31
+ | socketPath | FLAGD_SOCKET_PATH | string | - | |
32
+ | cache | FLAGD_CACHE | string | lru | lru,disabled |
33
+ | maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
34
+ | maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | |
35
35
 
36
- ### Example using TCP
36
+ ### Example Using TCP
37
37
 
38
38
  ```
39
39
  OpenFeature.setProvider(new FlagdProvider({
@@ -42,7 +42,7 @@ Options can be defined in the constructor or as environment variables, with cons
42
42
  }))
43
43
  ```
44
44
 
45
- ### Example using a Unix socket
45
+ ### Example Using a Unix Socket
46
46
 
47
47
  ```
48
48
  OpenFeature.setProvider(new FlagdProvider({
@@ -50,7 +50,7 @@ Options can be defined in the constructor or as environment variables, with cons
50
50
  }))
51
51
  ```
52
52
 
53
- ### Supported events
53
+ ### Supported Events
54
54
 
55
55
  The flagd provider emits `PROVIDER_READY`, `PROVIDER_ERROR` and `PROVIDER_CONFIGURATION_CHANGED` events.
56
56
 
@@ -62,12 +62,18 @@ The flagd provider emits `PROVIDER_READY`, `PROVIDER_ERROR` and `PROVIDER_CONFIG
62
62
 
63
63
  For general information on events, see the [official documentation](https://openfeature.dev/docs/reference/concepts/events).
64
64
 
65
+ ### Flag Metadata
66
+
67
+ | Field | Type | Value |
68
+ | ------- | ------ | ------------------------------------------------- |
69
+ | `scope` | string | "selector" set for the associated source in flagd |
70
+
65
71
  ## Building
66
72
 
67
73
  Run `nx package providers-flagd` to build the library.
68
74
 
69
75
  > NOTE: [Buf](https://docs.buf.build/installation) must be installed to build locally.
70
76
 
71
- ## Running unit tests
77
+ ## Running Unit Tests
72
78
 
73
79
  Run `nx test providers-flagd` to execute the unit tests via [Jest](https://jestjs.io).
package/index.cjs CHANGED
@@ -2682,7 +2682,7 @@ function newError(name) {
2682
2682
  configurable: true,
2683
2683
  },
2684
2684
  name: {
2685
- get: function get() { return name; },
2685
+ get() { return name; },
2686
2686
  set: undefined,
2687
2687
  enumerable: false,
2688
2688
  // configurable: false would accurately preserve the behavior of
@@ -2692,7 +2692,7 @@ function newError(name) {
2692
2692
  configurable: true,
2693
2693
  },
2694
2694
  toString: {
2695
- value: function value() { return this.name + ": " + this.message; },
2695
+ value() { return this.name + ": " + this.message; },
2696
2696
  writable: true,
2697
2697
  enumerable: false,
2698
2698
  configurable: true,
@@ -5980,7 +5980,9 @@ class GRPCService {
5980
5980
  this._streamConnectAttempt++;
5981
5981
  setTimeout(() => {
5982
5982
  this._streamConnectBackoff = this._streamConnectBackoff * 2;
5983
- this.connectStream(connectCallback, changedCallback, disconnectCallback);
5983
+ this.connectStream(connectCallback, changedCallback, disconnectCallback).catch(() => {
5984
+ // empty catch to avoid unhandled promise rejection
5985
+ });
5984
5986
  }, this._streamConnectBackoff);
5985
5987
  }
5986
5988
  else {
@@ -5992,7 +5994,7 @@ class GRPCService {
5992
5994
  }
5993
5995
  handleClose() {
5994
5996
  var _a, _b;
5995
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`${FlagdProvider.name}: streaming connection closed gracefully`);
5997
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`${FlagdProvider.name}: streaming connection closed`);
5996
5998
  (_b = this._cache) === null || _b === void 0 ? void 0 : _b.clear();
5997
5999
  this._streamAlive = false;
5998
6000
  }
@@ -6015,6 +6017,7 @@ class GRPCService {
6015
6017
  value: parser.call(this, response.value),
6016
6018
  reason: response.reason,
6017
6019
  variant: response.variant,
6020
+ flagMetadata: response.metadata,
6018
6021
  };
6019
6022
  logger.debug(`${FlagdProvider.name}: resolved flag with key: ${resolved.value}, variant: ${response.variant}, reason: ${response.reason}`);
6020
6023
  if (this._cacheActive && response.reason === jsSdk.StandardResolutionReasons.STATIC) {
package/index.js CHANGED
@@ -2678,7 +2678,7 @@ function newError(name) {
2678
2678
  configurable: true,
2679
2679
  },
2680
2680
  name: {
2681
- get: function get() { return name; },
2681
+ get() { return name; },
2682
2682
  set: undefined,
2683
2683
  enumerable: false,
2684
2684
  // configurable: false would accurately preserve the behavior of
@@ -2688,7 +2688,7 @@ function newError(name) {
2688
2688
  configurable: true,
2689
2689
  },
2690
2690
  toString: {
2691
- value: function value() { return this.name + ": " + this.message; },
2691
+ value() { return this.name + ": " + this.message; },
2692
2692
  writable: true,
2693
2693
  enumerable: false,
2694
2694
  configurable: true,
@@ -5976,7 +5976,9 @@ class GRPCService {
5976
5976
  this._streamConnectAttempt++;
5977
5977
  setTimeout(() => {
5978
5978
  this._streamConnectBackoff = this._streamConnectBackoff * 2;
5979
- this.connectStream(connectCallback, changedCallback, disconnectCallback);
5979
+ this.connectStream(connectCallback, changedCallback, disconnectCallback).catch(() => {
5980
+ // empty catch to avoid unhandled promise rejection
5981
+ });
5980
5982
  }, this._streamConnectBackoff);
5981
5983
  }
5982
5984
  else {
@@ -5988,7 +5990,7 @@ class GRPCService {
5988
5990
  }
5989
5991
  handleClose() {
5990
5992
  var _a, _b;
5991
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`${FlagdProvider.name}: streaming connection closed gracefully`);
5993
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`${FlagdProvider.name}: streaming connection closed`);
5992
5994
  (_b = this._cache) === null || _b === void 0 ? void 0 : _b.clear();
5993
5995
  this._streamAlive = false;
5994
5996
  }
@@ -6011,6 +6013,7 @@ class GRPCService {
6011
6013
  value: parser.call(this, response.value),
6012
6014
  reason: response.reason,
6013
6015
  variant: response.variant,
6016
+ flagMetadata: response.metadata,
6014
6017
  };
6015
6018
  logger.debug(`${FlagdProvider.name}: resolved flag with key: ${resolved.value}, variant: ${response.variant}, reason: ${response.reason}`);
6016
6019
  if (this._cacheActive && response.reason === StandardResolutionReasons.STATIC) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfeature/flagd-provider",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "scripts": {
5
5
  "publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi",
6
6
  "current-version": "echo $npm_package_version"