@openfeature/flagd-provider 0.13.0 → 0.13.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/README.md +18 -12
- package/index.cjs.js +9 -5
- package/index.esm.js +9 -5
- package/package.json +8 -8
- package/src/lib/configuration.d.ts +6 -6
- package/src/proto/ts/flagd/evaluation/v1/evaluation.d.ts +32 -575
- package/src/proto/ts/flagd/sync/v1/sync.d.ts +12 -73
- package/src/proto/ts/google/protobuf/struct.d.ts +8 -88
- package/src/proto/ts/schema/v1/schema.d.ts +32 -575
- package/src/proto/ts/sync/v1/sync_service.d.ts +8 -53
package/README.md
CHANGED
|
@@ -27,17 +27,23 @@ Options can be defined in the constructor or as environment variables. Construct
|
|
|
27
27
|
|
|
28
28
|
### Available Configuration Options
|
|
29
29
|
|
|
30
|
-
| Option name | Environment variable name | Type | Default
|
|
31
|
-
| -------------------------------------- | ------------------------------ | -------
|
|
32
|
-
| host | FLAGD_HOST | string | localhost
|
|
33
|
-
| port | FLAGD_PORT | number |
|
|
34
|
-
| tls | FLAGD_TLS | boolean | false
|
|
35
|
-
| socketPath | FLAGD_SOCKET_PATH | string | -
|
|
36
|
-
| resolverType | FLAGD_RESOLVER | string | rpc
|
|
37
|
-
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | string | -
|
|
38
|
-
| selector | FLAGD_SOURCE_SELECTOR | string | -
|
|
39
|
-
| cache | FLAGD_CACHE | string | lru
|
|
40
|
-
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000
|
|
30
|
+
| Option name | Environment variable name | Type | Default | Supported values |
|
|
31
|
+
| -------------------------------------- | ------------------------------ | ------- |----------------------------------------------------------------| ---------------- |
|
|
32
|
+
| host | FLAGD_HOST | string | localhost | |
|
|
33
|
+
| port | FLAGD_PORT | number | [resolver specific defaults](#resolver-type-specific-defaults) | |
|
|
34
|
+
| tls | FLAGD_TLS | boolean | false | |
|
|
35
|
+
| socketPath | FLAGD_SOCKET_PATH | string | - | |
|
|
36
|
+
| resolverType | FLAGD_RESOLVER | string | rpc | rpc, in-process |
|
|
37
|
+
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | string | - | |
|
|
38
|
+
| selector | FLAGD_SOURCE_SELECTOR | string | - | |
|
|
39
|
+
| cache | FLAGD_CACHE | string | lru | lru, disabled |
|
|
40
|
+
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
|
|
41
|
+
|
|
42
|
+
#### Resolver type-specific Defaults
|
|
43
|
+
|
|
44
|
+
| Option name | Environment variable name | in-process | rpc | default |
|
|
45
|
+
| -------------------------------------- | ------------------------------ |-------------|------|---------|
|
|
46
|
+
| port | FLAGD_PORT | 8015 | 8013 | 8013 |
|
|
41
47
|
|
|
42
48
|
Below are examples of usage patterns.
|
|
43
49
|
|
|
@@ -72,7 +78,7 @@ Flag configurations for evaluation are obtained via gRPC protocol using [sync pr
|
|
|
72
78
|
}))
|
|
73
79
|
```
|
|
74
80
|
|
|
75
|
-
In the above example, the provider expects a flag sync service implementation to be available at `localhost:
|
|
81
|
+
In the above example, the provider expects a flag sync service implementation to be available at `localhost:8015` (default host and port).
|
|
76
82
|
|
|
77
83
|
In-process resolver can also work in an offline mode.
|
|
78
84
|
To enable this mode, you should provide a valid flag configuration file with the option `offlineFlagSourcePath`.
|
package/index.cjs.js
CHANGED
|
@@ -17,13 +17,13 @@ const DEFAULT_MAX_CACHE_SIZE = 1000;
|
|
|
17
17
|
|
|
18
18
|
const DEFAULT_CONFIG = {
|
|
19
19
|
host: 'localhost',
|
|
20
|
-
port: 8013,
|
|
21
20
|
tls: false,
|
|
22
|
-
resolverType: 'rpc',
|
|
23
21
|
selector: '',
|
|
24
22
|
cache: 'lru',
|
|
25
23
|
maxCacheSize: DEFAULT_MAX_CACHE_SIZE,
|
|
26
24
|
};
|
|
25
|
+
const DEFAULT_RPC_CONFIG = Object.assign(Object.assign({}, DEFAULT_CONFIG), { resolverType: 'rpc', port: 8013 });
|
|
26
|
+
const DEFAULT_IN_PROCESS_CONFIG = Object.assign(Object.assign({}, DEFAULT_CONFIG), { resolverType: 'in-process', port: 8015 });
|
|
27
27
|
var ENV_VAR;
|
|
28
28
|
(function (ENV_VAR) {
|
|
29
29
|
ENV_VAR["FLAGD_HOST"] = "FLAGD_HOST";
|
|
@@ -59,7 +59,11 @@ const getEnvVarConfig = () => {
|
|
|
59
59
|
})));
|
|
60
60
|
};
|
|
61
61
|
function getConfig(options = {}) {
|
|
62
|
-
|
|
62
|
+
const envVarConfig = getEnvVarConfig();
|
|
63
|
+
const defaultConfig = options.resolverType == 'in-process' || envVarConfig.resolverType == 'in-process'
|
|
64
|
+
? DEFAULT_IN_PROCESS_CONFIG
|
|
65
|
+
: DEFAULT_RPC_CONFIG;
|
|
66
|
+
return Object.assign(Object.assign(Object.assign({}, defaultConfig), envVarConfig), options);
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
/******************************************************************************
|
|
@@ -6612,7 +6616,7 @@ class FileFetch {
|
|
|
6612
6616
|
dataFillCallback(output);
|
|
6613
6617
|
// Using watchFile instead of watch to support virtualized host file systems.
|
|
6614
6618
|
fs.watchFile(this._filename, () => __awaiter(this, void 0, void 0, function* () {
|
|
6615
|
-
var
|
|
6619
|
+
var _a;
|
|
6616
6620
|
try {
|
|
6617
6621
|
const data = yield fs.promises.readFile(this._filename, encoding);
|
|
6618
6622
|
const changes = dataFillCallback(data);
|
|
@@ -6621,7 +6625,7 @@ class FileFetch {
|
|
|
6621
6625
|
}
|
|
6622
6626
|
}
|
|
6623
6627
|
catch (err) {
|
|
6624
|
-
(
|
|
6628
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`Error reading file: ${err}`);
|
|
6625
6629
|
}
|
|
6626
6630
|
}));
|
|
6627
6631
|
}
|
package/index.esm.js
CHANGED
|
@@ -13,13 +13,13 @@ const DEFAULT_MAX_CACHE_SIZE = 1000;
|
|
|
13
13
|
|
|
14
14
|
const DEFAULT_CONFIG = {
|
|
15
15
|
host: 'localhost',
|
|
16
|
-
port: 8013,
|
|
17
16
|
tls: false,
|
|
18
|
-
resolverType: 'rpc',
|
|
19
17
|
selector: '',
|
|
20
18
|
cache: 'lru',
|
|
21
19
|
maxCacheSize: DEFAULT_MAX_CACHE_SIZE,
|
|
22
20
|
};
|
|
21
|
+
const DEFAULT_RPC_CONFIG = Object.assign(Object.assign({}, DEFAULT_CONFIG), { resolverType: 'rpc', port: 8013 });
|
|
22
|
+
const DEFAULT_IN_PROCESS_CONFIG = Object.assign(Object.assign({}, DEFAULT_CONFIG), { resolverType: 'in-process', port: 8015 });
|
|
23
23
|
var ENV_VAR;
|
|
24
24
|
(function (ENV_VAR) {
|
|
25
25
|
ENV_VAR["FLAGD_HOST"] = "FLAGD_HOST";
|
|
@@ -55,7 +55,11 @@ const getEnvVarConfig = () => {
|
|
|
55
55
|
})));
|
|
56
56
|
};
|
|
57
57
|
function getConfig(options = {}) {
|
|
58
|
-
|
|
58
|
+
const envVarConfig = getEnvVarConfig();
|
|
59
|
+
const defaultConfig = options.resolverType == 'in-process' || envVarConfig.resolverType == 'in-process'
|
|
60
|
+
? DEFAULT_IN_PROCESS_CONFIG
|
|
61
|
+
: DEFAULT_RPC_CONFIG;
|
|
62
|
+
return Object.assign(Object.assign(Object.assign({}, defaultConfig), envVarConfig), options);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
/******************************************************************************
|
|
@@ -6608,7 +6612,7 @@ class FileFetch {
|
|
|
6608
6612
|
dataFillCallback(output);
|
|
6609
6613
|
// Using watchFile instead of watch to support virtualized host file systems.
|
|
6610
6614
|
watchFile(this._filename, () => __awaiter(this, void 0, void 0, function* () {
|
|
6611
|
-
var
|
|
6615
|
+
var _a;
|
|
6612
6616
|
try {
|
|
6613
6617
|
const data = yield promises.readFile(this._filename, encoding);
|
|
6614
6618
|
const changes = dataFillCallback(data);
|
|
@@ -6617,7 +6621,7 @@ class FileFetch {
|
|
|
6617
6621
|
}
|
|
6618
6622
|
}
|
|
6619
6623
|
catch (err) {
|
|
6620
|
-
(
|
|
6624
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`Error reading file: ${err}`);
|
|
6621
6625
|
}
|
|
6622
6626
|
}));
|
|
6623
6627
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfeature/flagd-provider",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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"
|
|
7
7
|
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@openfeature/flagd-core": "~0.1.10",
|
|
10
|
-
"@protobuf-ts/runtime-rpc": "2.9.4",
|
|
11
|
-
"lru-cache": "10.2.0",
|
|
12
|
-
"util": "0.12.5"
|
|
13
|
-
},
|
|
14
8
|
"peerDependencies": {
|
|
15
9
|
"@grpc/grpc-js": "~1.8.0 || ~1.9.0 || ~1.10.0",
|
|
16
10
|
"@openfeature/server-sdk": "^1.13.0"
|
|
@@ -24,5 +18,11 @@
|
|
|
24
18
|
}
|
|
25
19
|
},
|
|
26
20
|
"module": "./index.esm.js",
|
|
27
|
-
"main": "./index.cjs.js"
|
|
21
|
+
"main": "./index.cjs.js",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@openfeature/flagd-core": "0.2.3",
|
|
24
|
+
"@protobuf-ts/runtime-rpc": "2.9.4",
|
|
25
|
+
"lru-cache": "10.2.2",
|
|
26
|
+
"util": "0.12.5"
|
|
27
|
+
}
|
|
28
28
|
}
|
|
@@ -63,10 +63,10 @@ export declare function getConfig(options?: FlagdProviderOptions): {
|
|
|
63
63
|
host: string;
|
|
64
64
|
port: number;
|
|
65
65
|
tls: boolean;
|
|
66
|
-
socketPath?: string
|
|
67
|
-
resolverType?: ResolverType
|
|
68
|
-
offlineFlagSourcePath?: string
|
|
69
|
-
selector?: string
|
|
70
|
-
cache?: CacheOption
|
|
71
|
-
maxCacheSize?: number
|
|
66
|
+
socketPath?: string;
|
|
67
|
+
resolverType?: ResolverType;
|
|
68
|
+
offlineFlagSourcePath?: string;
|
|
69
|
+
selector?: string;
|
|
70
|
+
cache?: CacheOption;
|
|
71
|
+
maxCacheSize?: number;
|
|
72
72
|
};
|